Community Forums › Forums › Archived Forums › Design Tips and Tricks › Remove CPT Entry Header and Footer on Search Results
- This topic has 4 replies, 3 voices, and was last updated 8 years, 2 months ago by hortonsart.
-
AuthorPosts
-
March 15, 2016 at 1:46 pm #181470hortonsartMember
I'm building a site using a couple of different Custom Post Types (CPT). I've created single templates for these CPT and have removed the entry header post info and entry footer meta and the markup for the entry header and entry footer from displaying.
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 ); remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 ); remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
For some reason when I use the search form and perform a search these results come up, along with other blog posts, and the entry header and footer information shows up again. Is there another template that I need to modify to not display this information on search results for these CPT?
Any help is greatly appreciated.
March 16, 2016 at 6:57 am #181527Victor FontModeratorUnless your theme has a search.php file, it is using the default WordPress search results page. You can create your own search results page and customize it any way you'd like: https://codex.wordpress.org/Creating_a_Search_Page
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?March 17, 2016 at 1:52 pm #181726hortonsartMemberThanks Victor. I guess I'm not understanding, or maybe were talking about two different things? The post types that are included in the search results are fine. I want the custom post types, pages and posts to show up in the results and they are. What I don't want is the entry header (post info) and entry footer (post meta) to be displayed on the results of my custom post types when being displayed in the search results, because they're more like pages (It doesn't matter what category they belong to, what date they were published, or which author actually published the custom post type etc.). I thought removing these items through their respective custom post type single templates would carry over into the search results?
For example let's say I have the following Post Types
- Pages
- Posts
- Products (Custom Post Type with entry_header_markup, post_info, entry_footer_markup, and post_meta removed in the single template -> single-products.php)Let's also say I've written a blog post that references one of these "Products" in its body. When I perform a search I get the blog post I wrote and the "product" posting in the results. This is great and what I want to happen, but both results are now being displayed with the date and the author and the number of comments, which is fine for a blog post because those elements are important, but I've removed those elements on the Products postings because that information doesn't matter.
For the time being I've just removed this info via CSS. If anyone knows a better way to do this please let me know.
October 26, 2016 at 1:56 pm #195365HParticipantDid you salve this @hortonsart? I want to do the exact same thing and haven't found any solution.
October 26, 2016 at 4:36 pm #195374hortonsartMemberHi Josh, I opted for a CSS approach to solve this problem by targeting the body class of "search" and the post class for my cpt to hide the entry meta.
.search .your-custom-post-type-class-here .entry-meta { display: none; }
All searches on your site should have a body class of "search" by default and all of your custom post types should have a custom post class by default as well. Let me know if you run into any problems.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.