• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Remove a word from end of post titles

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Remove a word from end of post titles

This topic is: not resolved

Tagged: change, filter, post, title

  • This topic has 6 replies, 2 voices, and was last updated 11 years, 9 months ago by hansel.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • February 7, 2014 at 9:59 am #89136
    hansel
    Member

    I would like to remove the last word of post titles (only on home and category pages).
    I tried this (and many more) but I can't get it to work.

    This does not work:

    
    if ( is_home() || is_category() ) {
    	add_filter( 'genesis_post_title_output', 'child_remove_stupidword_from_titles' );
    	function child_remove_stupidword_from_titles( $title ) {
    		return preg_replace( 'stupidword$', '', $title );
    	}
    }
    

    How can I change the post title? I already tried many different hooks and no google results can help me out... Someone please help me out! 🙂

    February 7, 2014 at 10:54 am #89145
    ramseyp
    Member

    The hook that touches the title text is genesis_post_title_text, not genesis_post_title_output. Try running add_filter on that & see if it works.


    Community • Work • Conversations

    February 7, 2014 at 11:18 am #89150
    hansel
    Member

    Unfortunately this doesn't work either.

    Right now I have this in functions.php and it does nothing:

    
    if ( is_home() || is_category() ) {
    	add_filter( 'genesis_post_title_text', 'child_remove_stupidword_from_titles' );
    	function child_remove_stupidword_from_titles( $title ) {
    		return preg_replace( 'stupidword$', '', $title );
    	}
    }
    

    🙁 I hope someone can point me in the right direction...

    February 10, 2014 at 5:57 am #89618
    hansel
    Member

    I sure hope someone comes along to help me...
    I had no luck over the weekend trying to fix this myself.

    February 20, 2014 at 4:03 pm #91498
    hansel
    Member

    Is there really no way to do this?

    February 20, 2014 at 4:23 pm #91500
    ramseyp
    Member

    Hi Hansel,

    You want to rework your filter function a bit. You need to return $title, and the conditionals need to be moved inside the function, around what is to be changed when those conditionals are met. I used a different method of stripping the last word & it works well. I don't know if using substr with strrpos way is faster than using preg_replace, but that would be an option, too, I think.

    function child_remove_stupidword_from_titles( $title ) {
    	if ( is_home() || is_category() ) { 
    		$title = substr($title, 0, strrpos($title, " "));
    	}
    	return $title;
    }
    add_filter( 'genesis_post_title_text', 'child_remove_stupidword_from_titles' );

    Community • Work • Conversations

    February 24, 2014 at 8:24 am #92125
    hansel
    Member

    For me this removes the entire title... I just want the last word of the title removed...

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble