• Hello,

    I try to remove and replace this box:

    <!-- This site is optimized with the Yoast SEO plugin v2.3.4 - https://yoast.com/wordpress/plugins/seo/ -->
    <meta name="description" content=" "/>
    <link rel="canonical" href="https://" />
    <meta property="og:locale" content="de_DE" />
    <meta property="og:type" content=" " />
    <meta property="og:title" content=" " />
    <meta property="og:description" content=" " />
    <meta property="og:url" content=" " />
    <meta property="og:site_name" content=" " />
    <!-- / Yoast SEO plugin. -->

    Actually, I try it with this code:

    function my_title($title,$separator,$position) {
            if(isset($_GET['article_id'])){
                    remove_action('wp_head','jetpack_og_tags'); // JetPack
                    if (defined('WPSEO_VERSION')) { // Yoast SEO
                            global $wpseo_front;
                            remove_action('wp_head',array($wpseo_front,'head'),30);
                    }
    
                    remove_action('wp_head','wpseo_opengraph');
                    remove_action('wp_head','canonical');
                    remove_action('wp_head','index_rel_link');
                    remove_action('wp_head','start_post_rel_link');
                    remove_action('wp_head','adjacent_posts_rel_link_wp_head');
            }
            return $title;
    }
    add_filter('wp_title','my_title',20,3);

    I don’t get it…it’s still there. The reason is that I got some dynamic content which isn’t a real site in wordpress, so I like to replace the meta tags.

    Thanks!

    Bj?rn

Viewing 1 replies (of 1 total)
  • Thread Starter peacefulwarri0r

    (@peacefulwarri0r)

    Meanwhile I figured out to replace the og title, the title and the canonical. But og:description and the description I couldn’t.

    function bth_title($title,$seperator,$position) {
            if(isset($_GET['article_id']) && $_GET['article_id'] != ""){
                    global $wpdb;
                    global $wpseo_og;
    
                    $bth_article = $wpdb->get_results( "SELECT * from articles where id=".$_GET['article_id'].";" );
    
                    // remove og_title
                    remove_action( 'wpseo_opengraph', array( $wpseo_og, 'og_title' ) );
                    // remove canonical
                    add_filter( 'wpseo_canonical', '__return_false' );
    
                    // add og_title and image
                    add_action( 'wpseo_opengraph', 'my_og');
                    // add canonical
                    add_action( 'wp_head', 'my_rel_canonical');
    
                    // title
                    $product_name = preg_replace('/^\/(.*)\/(.*)?/', '${1}', $_SERVER[REQUEST_URI]);
                    $title = ucfirst($product_name)." - ".$bth_article[0]->headline1." - PageName";
            }
            return $title;
    }
    add_filter('wp_title','bth_title',20,3);
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Yoast SEO] Problem to remove og tags’ is closed to new replies.