• 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

genesis_title showing outside tag with Simple Hooks

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 › General Discussion › genesis_title showing outside tag with Simple Hooks

This topic is: not resolved

Tagged: Simple Hooks, title

  • This topic has 7 replies, 3 voices, and was last updated 11 years ago by Carlo.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • December 29, 2014 at 7:05 am #135530
    mswas
    Member

    I'm trying to replace the post title using Simple hooks. In the Document Hooks> genesis_title Hook: it says "This hook executes between the main document <title></title> tags." but whatever I place in that field shows AFTER the </title> tag.

    My current theme is Beautiful Pro, but this happened with Metro and also just Genesis.

    January 9, 2015 at 10:08 pm #136826
    Tom
    Participant

    Please post the code exactly as you are using it.
    (don't forget to use the "code" tags on your forum post)


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    January 10, 2015 at 5:13 am #136834
    Carlo
    Member

    I don't know why it says the hook executes between the title tags, because that's not how it works.

    However, you can replace the post title in your post editing screen under 'Custom Document Title'.

    Or, if you want to use a hook, you can use the wp_title hook like this, in your theme functions:

    add_filter( 'wp_title', function() {
    	return 'My Replaced Title';
    }, 20 );

    or if you want to keep the title but add content to it, this should work:

    add_filter( 'wp_title', function( $old_title ) {
    	return sprintf( 'My Old Title was %s', $old_title );
    }, 20 );

    Comprehensive, easy to follow Genesis documentation

    January 10, 2015 at 5:16 am #136835
    mswas
    Member

    Thanks Tom, this occurs with PHP and plain text. This is what I currently have in the genesis_title Hook field. with "Execute PHP on this hook?" checked.

    | <?php echo get_field('book_title') . ' by ' . get_field('book_author') ; ?> Book Review

    See that it is showing just outside </title> here: http://cannonballread.com/2015/01/afterworlds-if-schrodinger-ever-wrote-a-book/

    <title>Afterworlds; If Schrödinger ever wrote a book</title>| Afterworlds by Scott Westerfeld Book Review

    January 10, 2015 at 5:23 am #136838
    mswas
    Member

    Carlo, I was writing my reply when you posted... Thanks for your suggestion. But this will not work for me to require the author to change on the post editing screen. We have over 170 bloggers now and it is very hard to get them every single one of them to do something consistently. I want this automated based on other custom fields that they are required to enter.

    You can see my confusion based on what it says in the SH dashboard. I could have sworn that there was a field to append/replace title in previous versions of SH but maybe I was mistaken.

    (edit - will try your other code tho.)

    January 11, 2015 at 10:25 am #137050
    Carlo
    Member

    I see what you want to do now. Try this code: (it's the same idea as what I posted before the but tailored to match the format you posted)

    add_filter( 'wp_title', function( $old_title ) {
    	return sprintf( '%s | %s by %s Book Review', $old_title, get_field( 'book_title' ), get_field( 'book_author' ) );
    }, 20 );

    Comprehensive, easy to follow Genesis documentation

    January 12, 2015 at 3:50 am #137144
    mswas
    Member

    Thanks Carlo, that is a much simpler bit of code than what I had found!

    March 9, 2015 at 2:12 am #143757
    Carlo
    Member

    I recently published a tutorial on this topic:
    http://carlomanf.id.au/modify-title-tags/


    Comprehensive, easy to follow Genesis documentation

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘General Discussion’ 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

© 2026 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