0

I'm trying to change the order of the title tag and description tag (CMS Wordpress, plugin Yoast SEO). Now in the code of the page it looks like this:

<title>something ...</title>
<meta name="description" content="something ..."/>

And I want to do this:

<meta name="description" content="something ..."/>
<title>something ...</title>

I tried this snippet in function.php, but this code does not work correctly

   add_filter( 'wpseo_title', '__return_false' );
   add_filter( 'wpseo_title', 'filter_wpseo_title', 90);
   add_filter( 'wpseo_metadesc', '__return_false' );
   add_filter( 'wpseo_metadesc', 'filter_wpseo_title', 10);

1 Answer 1

0

Here is the working example of this please try this I tried for change for a page meta description by page id and solution is

    add_filter('wpseo_metadesc', function($description){
        global $post;
       $parent_post_id = wp_get_post_parent_id($post);
        $parent_post = get_post($parent_post_id);
        //$parent_post1 = get_children($parent_post_id);
        //echo "<pre>"; print_r($parent_post1->post_title); die();
        $parent_post_title = $parent_post->post_title;
        $name= get_the_title();

            if( is_page( array( 157, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 188, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216) ) ) {
                   $description = $name."post office locations listed alphabetically with complete temporary and permanent change of address assistance online.";
            }
            if( is_page( array( 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215) ) ) {
                   $description = $name."post office addresses alphabetically organized offering temporary and permanent address change assistance online.";
            }
            return $description;
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.