• Resolved Novalyyn

    (@novalyyn)


    In the plugin I’m working I’m trying to filter a little piece into the titles of posts, but only when that post is being shown. I have a quick is_single() check to prevent it from showing up on other pages.

    However, it’s being added to all titles on the single post page, including titles in navigation and links to other posts. I was thinking that I might be able to make it show only for the post by telling it to work only while dealing with things in the loop, but I’m not sure how to go about doing that.

    What I have presently is basically:

    function display_string( $title ) {
      if ( ! is_single() ) {
        return $title;
      }
    
      $my_string = 'test value';
      return $my_string . $title;
    }
    
    add_filter( 'the_title', 'display_string' );
Viewing 1 replies (of 1 total)
  • Thread Starter Novalyyn

    (@novalyyn)

    Found it, once I finally figured out how to phrase the search.

    in_the_loop()

    Feel a tad dumb, but more happy that I got it.

Viewing 1 replies (of 1 total)
  • The topic ‘Filter to post title only’ is closed to new replies.