Title: functions.php modify title function changes secondary menu
Last modified: August 30, 2016

---

# functions.php modify title function changes secondary menu

 *  [mgargiullo](https://wordpress.org/support/users/mgargiullo/)
 * (@mgargiullo)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/functionsphp-modify-title-function-changes-secondary-menu/)
 * I’m running the syntax theme on my site. I have a function in my child theme’s
   functions.php file that modifies the post titles. The problem I have is that 
   it also modifies the post navigation links (shown as titles) at the bottom of
   the post.
 * I used doing_filter to check for one of the plugins so I can skip modifying it
   like so:
 * `if(doing_filter('cmtt_tooltip_content_add')){ return $title; }`
 * How do I check to see if my title function is operating on a navigation link 
   so I can skip modifying it?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/functionsphp-modify-title-function-changes-secondary-menu/#post-6602687)
 * Offhand I’m not sure. Can you make your function more specific so it targets 
   a more specific element that doesn’t include the post navigation.
 * Can you provide a link to your site?
 *  Thread Starter [mgargiullo](https://wordpress.org/support/users/mgargiullo/)
 * (@mgargiullo)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/functionsphp-modify-title-function-changes-secondary-menu/#post-6602693)
 * Sure. [http://nyc.books.plantsofsuburbia.com](http://nyc.books.plantsofsuburbia.com)
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/functionsphp-modify-title-function-changes-secondary-menu/#post-6602698)
 * What element are you targeting with your function? Can you target just `.entry-
   header .entry-title` ?
 *  Thread Starter [mgargiullo](https://wordpress.org/support/users/mgargiullo/)
 * (@mgargiullo)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/functionsphp-modify-title-function-changes-secondary-menu/#post-6602769)
 * I can’t just touch the css unfortunately as the function that creates the 3 style
   post title assigns a style to each piece.
 * [Image of Post Title](https://monosnap.com/file/c5Py2Bfpx7du8NFun7R7xjU1KFZCe5.png)
 * The title of the post is entered like so:
    Aegilops cylindrica|jointed goat-grass
   |Poaceae
 * This function beaks it apart and reformats it.
 *     ```
       function change_post_title($title) {
       	if(doing_filter('cmtt_tooltip_content_add')){ return $title; }
       	$cpt_tmp_title=explode("|",$title);
       	if ( in_the_loop() ) {
                       return " <span class=\"mtitle-latinname\">".$cpt_tmp_title[0]." </span><span class=\"mtitle-commonname\">".$cpt_tmp_title[1]." </span><span class=\"mtitle-familyname\">".$cpt_tmp_title[2]."</span>";
               }
       }
       ```
   
 * At the bottom of the page, the post navigation is also formatted like the title:
 * [Post Navigation](https://monosnap.com/file/sxzQIAcm4fFNbJ51C6YFTqHLWLMLll.png)
 * I’d like to modify the post navigation titles. Obviously the post navigation 
   uses titles as it gets formatted. I’m looking for the right IF statement to use
   to identify when we’re modifying the titles used in post navigation or specifically
   the post title shown at the top of the page.
 * In the code above, I already have a check in the function so I don’t modify the
   glossary terms.
 * Ideally it would look like this (pseudo code):
 *     ```
       function change_post_title($title) {
       	if(doing_filter('cmtt_tooltip_content_add')){ return $title; }
       	$cpt_tmp_title=explode("|",$title);
       	if ( in_the_loop() ) {
                       if(this is the main post title){
                               return " <span class=\"mtitle-latinname\">".$cpt_tmp_title[0]." </span><span class=\"mtitle-commonname\">".$cpt_tmp_title[1]." </span><span class=\"mtitle-familyname\">".$cpt_tmp_title[2]."</span>";
                       }else{
                                return " <span class=\"smmtitle-latinname\">".$cpt_tmp_title[0]." </span><span class=\"smmtitle-commonname\">".$cpt_tmp_title[1]." </span><span class=\"smmtitle-familyname\">".$cpt_tmp_title[2]."</span>";
                       }
               }
       }
       ```
   
 * Ideally, I could assign a different class to the post navigation titles vs. the
   post title.
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/functionsphp-modify-title-function-changes-secondary-menu/#post-6602823)
 * Ah, gotcha – thanks for explaining in more detail what you’re doing.
 * My colleague and I both looked at this and we couldn’t think of any other parameters
   to add to the `in_the_loop()` function or any other conditions to add to your
   current function so that it excludes the title in the post navigation.
 * Another route to go would be directly modifying `the_title()` output instead,
   but I’m wondering if a simpler route would just be to override the CSS itself
   to return the post navigation to a simpler display.
 * For example, you could try adding something like this to your child theme:
 *     ```
       .navigation-post .mtitle-latinname, .navigation-post .mtitle-commonname, .navigation-post .mtitle-familyname {
         color: #000;
         font-size: 16px;
         font-weight: normal;
       }
       ```
   
 * Let me know if that would work for you.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘functions.php modify title function changes secondary menu’ is closed
to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/syntax/1.1.0/screenshot.png)
 * Syntax
 * [Support Threads](https://wordpress.org/support/theme/syntax/)
 * [Active Topics](https://wordpress.org/support/theme/syntax/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/syntax/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/syntax/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/functionsphp-modify-title-function-changes-secondary-menu/#post-6602823)
 * Status: not resolved