Forum Replies Created
-
AuthorPosts
-
March 21, 2023 at 12:19 am in reply to: Removing Title and Metadata for posts in a specific category #507009mitchelyParticipant
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
-
AuthorPosts