• 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

Adding ID's to post

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 › Adding ID's to post

This topic is: resolved

Tagged: attributes

  • This topic has 2 replies, 2 voices, and was last updated 11 years, 4 months ago by petervk.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • May 10, 2015 at 9:29 am #151481
    petervk
    Member

    Hi all, I'm trying to add HTML ID's with the posts title to each of my posts.

    This is my current code within functions.php:

    //* add HTML ids to posts
    add_filter( 'genesis_attr_entry', 'themeprefix_entry_id' );
    function themeprefix_entry_id( $attributes ) {

    $attributes['id'] =' <?php echo get_the_title(); ?>';
    return $attributes;
    }

    I've tried a few variations on this. It adds an id but the id is '<?php echo get_the_title(); ?>'
    I'm fairly new to PHP/Genesis/Wordpress so I hope I'm making a simple mistake. The WP function the_title() or get_the_title() won't operate within the genesis assignation.
    Let me know if you know the solution.

    May 10, 2015 at 10:00 am #151502
    vajrasar
    Member

    Try this instead -

    add_filter( 'genesis_attr_entry-title', 'custom_id_title' );
    function custom_id_title( $attributes ) {
    	
    	$id = get_the_ID();
     
    	$attributes['id'] = $id;
    
    	return $attributes;
     
    }

    I make WordPress websites using Genesis Framework.

    WordPress/Genesis Development | Customizations

    May 10, 2015 at 10:05 am #151507
    petervk
    Member

    Thanks a lot! This generates the ID number of the post, but that suits my purposes just fine.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 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

© 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