• 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

Removing Title and Metadata for posts in a specific category

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 › General Genesis Framework Discussions › Removing Title and Metadata for posts in a specific category

This topic is: not resolved

Tagged: category, metadata, posts

  • This topic has 1 reply, 2 voices, and was last updated 5 days, 15 hours ago by mitchely.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 17, 2023 at 10:44 am #506996
    hubs
    Participant

    I'm trying to remove the title, metadata above the post (date, author, leave a comment, edit) , and the metadata below the post (category and tags), and the post permalink. But only for posts in a specific category. I'm using the code below but can't seem to get it working. Any ideas?

    I'd also like to only remove the above items from the front page, not from the single page.

    //* Customize the post info function
    remove_action( 'genesis_entry_content', 'remove_metadata_asides' );
    function remove_metadata_asides($post_info) {
    if ( !is_page() ) {
    	remove_action( 'genesis_entry_content', 'genesis_do_post_permalink', 14 );
    	remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
    }}
    http://www.artifacting.com
    March 21, 2023 at 12:19 am #507009
    mitchely
    Participant

    Here's the modified code that should work to remove the title, metadata above the post (date, author, leave a comment, edit), metadata below the post (category and tags), and the post permalink from posts in a specific category:

    scss
    Copy code
    //* Customize the post info function
    add_action( 'genesis_before_entry', 'remove_metadata_asides' );
    function remove_metadata_asides() {
    if ( !is_singular('post') && has_category('category-slug') ) {
    remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
    remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
    remove_action( 'genesis_entry_content', 'genesis_do_post_permalink', 14 );
    }
    }
    Here's what this code does:

    It hooks into the genesis_before_entry action, which is executed before the post entry is displayed.
    It checks if the post is not a singular post (i.e., not a single post page) and has the category you want to target. You need to replace category-slug with the actual slug of your target category.
    If the post meets the conditions, it removes the post title, post info (date, author, leave a comment, edit), post meta (category and tags), and post permalink.
    Note that this code will only affect the front page and archive pages, not single post pages. If you want to remove the same elements from single post pages, you can modify the code to remove the actions from the genesis_entry_header, genesis_entry_content, and genesis_entry_footer hooks.

    Hope that helps

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

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