admin管理员组

文章数量:1334796

I need to change my site tag line. Basically, this is school site we create for xyz higher sec school and ABC Nursery school; so I need to add both as a tag line in my site if I use xyz higher sec school I can't be able to use ABC NURSERY for those particular pages.

I need to change tagline for around only 6 pages; kindly suggest me for that.

I need to change my site tag line. Basically, this is school site we create for xyz higher sec school and ABC Nursery school; so I need to add both as a tag line in my site if I use xyz higher sec school I can't be able to use ABC NURSERY for those particular pages.

I need to change tagline for around only 6 pages; kindly suggest me for that.

Share Improve this question edited Jun 1, 2020 at 23:42 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Jun 1, 2020 at 13:07 Arumugam GArumugam G 132 bronze badges 3
  • 1 If I'm understanding correctly it sounds like you will need to create a child theme, and instead of outputting the site tagline for certain pages, you'll need a conditional to output the other wording you want to appear there. – WebElaine Commented Jun 1, 2020 at 13:26
  • yes obviously correct – Arumugam G Commented Jun 1, 2020 at 13:40
  • Welcome to WordPress Development. I hope you find the answer(s) you are looking for. Our site is different from most - if you have not done so yet, consider checking out the tour and help center to find out how things work. – Matthew Brown aka Lord Matt Commented Jun 1, 2020 at 19:16
Add a comment  | 

1 Answer 1

Reset to default 1

If your theme is using the WordPress site tagline, you should be able to filter it. get_bloginfo( 'description' ) will call get_option( 'blogdescription' );, and we can filter the value of an option using the option_{$option} hook.

Let's suppose, for this code sample, that you want to change the tagline on 3 pages, with the titles Kindergarten, Nursery School, and Babysitting.

add_filter( 'option_blogdescription', 'wpse368031_change_tagline' );
function wpse368031_change_tagline( $tagline ) {
    $pages = array( 'Kindergarten', 'Nursery School', 'Babysitting' );
    if ( is_page( $pages ) ) {
        $tagline = 'ABC Nursery';
    }
    return $tagline;
}

Try adding this code to your active theme's functions.php file.

Reference

  • get_bloginfo( 'description' )
  • option_{$option} hook
  • is_page()

本文标签: navigationhow to change site tag line for particular pages