Community Forums › Forums › Archived Forums › Design Tips and Tricks › Trying to remove excerpt from Search Results page only
Tagged: search, search.php
- This topic has 11 replies, 3 voices, and was last updated 4 years, 8 months ago by Brad Dalton.
-
AuthorPosts
-
January 2, 2020 at 3:23 pm #495743webmonkeyMember
Hey folks,
I am trying to remove the Excerpt from the Search Results page only.
I've done it successfully from Category pages which retain two custom fields I have under the title, but on the search results page, while the Excerpt is indeed gone, it has also removed the custom fields.
It would be super easy to do if the excerpt <p> tags had a class! But they don't.
I am not sure why search results would behave differently than other Archive pages.
If anyone knows a way of inserting a class into JUST the search results page's Excerpt paragraph tags, that would likely be the path of least resistance.
Here's the CSS that successfully knocks out the Excerpt (but not the two custom fields) on Archive pages, but does knock it out on Search Results pages. A mystery that's been taking too long to solve...
body.archive p.entry-meta {display:none;} body.archive article.post p {display:none;}
If I remove this, the two custom fields DO appear on the search results but also the auto-generated Genesis Excerpt. If only it had a class in it's <p> tag.....
I'm using Metro Pro but suspect that's nothing to do with it.
It's a production site, so no URL, sorry.
January 2, 2020 at 3:52 pm #495744AnitaCKeymasterTry this:
.search-results div.entry-content, .search-results p.entry-meta { display: none; }
That's removing the excerpt and the entry-meta with the date and leave a comment.
**I updated the code**
Need help with customization or troubleshooting? Reach out to me.
January 3, 2020 at 1:00 pm #495751webmonkeyMemberThanks Anita!
That worked perfectly (in that it preserved the two custom fields) but had the unwanted effect of removing the thumbnail from search results.
It seems that the part:
.search-results div.entry-content
deals with both the thumbnail and the excerpt.It's a shame there's no class on the excerpt itself. That would have been the easiest way...
Any ideas? I'm grateful for any help you can give in resolving this.
January 3, 2020 at 4:13 pm #495756AnitaCKeymaster@webmonkey you want to keep the title and the featured image on the search results? I don't have Metro installed anywhere. Sridhar has this post (Method 1). Could you do
is_search
on this so that it pulls the images out of there, and then the CSS would work like it should?
Need help with customization or troubleshooting? Reach out to me.
January 3, 2020 at 10:24 pm #495760webmonkeyMemberWhat I had going on showed the title and thumbnail, but was missing the two custom fields.
What you posted preserved the title and the two custom fields but lost the thumbnail.
See this image for what I'm aiming for: https://www.dropbox.com/s/8ryemk9llyboylt/ideal-archive.png?dl=0
If there was a way I could insert a class into the <p> tag around all excerpt text, that would be the simplest. Then I could just hide the unwanted Excerpt using CSS.
Here's the code that's putting the two custom fields on archive pages:
<?php if ( is_archive() || is_front_page() || is_search() || is_tag() ) { echo '<div class="archive-title" align="center">'; genesis_do_post_title(); echo '</div>'; if( genesis_get_custom_field( 'gfm-artist' )) echo '<div class="archive-details" align="center"><p><span class="archive-field-name">Artist:</span> <span class="archive-field-value">' . genesis_get_custom_field( 'gfm-artist' ) .'</span><br>'; if( genesis_get_custom_field( 'gfm-price' ) && ! in_category( '571' )) echo '<span class="archive-field-name">Price:</span> <span class="strike archive-field-value">' . genesis_get_custom_field( 'gfm-former-price' ) . '</span> <span class="archive-field-value">' . genesis_get_custom_field( 'gfm-price' ) .'</span></p></div>'; } ?>
January 3, 2020 at 10:30 pm #495761webmonkeyMemberPS: That image is how it looks like on regular Archive pages where it's working. It works on Archive pages, tag pages, etc., but for some reason behaves differently on the Search Results page.
January 4, 2020 at 9:11 am #495768webmonkeyMemberI mean the point is that it works fine in every other archive page situation except the Search Results.
Genesis is frustrating. Every time I do another site, I run into the same frustrating problems. There are some super basic things that should be built into the theme that are not.
• Logo handling. Why can't Genesis offer a simple solution for logos, where you can upload a desktop and mobile version. It's the most basic identity customization for any website. Genesis tends to offer only one fixed size which may or may not fit the orientation of the client logo, and looks crappy on either mobile or desktop. Basic. Trying to figure this out for each new site is a total waste of time. Build it in.
• Archive display. Really, Studiopress can't build in a bunch of options for how archive pages (what we used to call "index" pages) display post listings? Offer a variety of thumbnail options (full width, square and aligned, etc) in a checkbox/pulldown menu environment. Do you want an excerpt to display. Have this customizable category by category, on the search results page, and on the tag archives separately. But everything has to be coded?
Half the themes don't even include the standard Category description. Amateur hour. Don't disable standard parts of WordPress and don't sell themes that do that. Build it in.
I don't want to be spending half a client project trying to figure out what used to be super simple on the Internet. It makes me think StudioPress has no actual staff with a design focus and has delegated its user experience to programmers who aren't end users.
The whole point of a CMS is to make things easier. It didn't help that StudioPress changed the names of all of its hooks at that last major update of Genesis. And that's such a programmer solution to customization. Get with useability. You'd see half the number the posts on this forum if StudioPress offered more simple customizability. That's why I've been using Divi for about half the sites I do. Because StudioPress requires too much effort to customize.
Back in the day, there was a StudioPress theme called Prose that attempted to do this kind of thing. It was pre-responsive so useless today, but that kind of idea was never explored further.
You're selling to designers, not programmers. Heck even the client should be able to go into the backend and change simple things like font size without going to university to learn how. I'm beyond frustrated with StudioPress. Get some UX people to audit your themes. Build into Genesis some of these things so your rando template designers can't mess things up. Every theme I purchase might as well be from a completely different company. There's no consistency.
January 5, 2020 at 10:38 am #495798AnitaCKeymaster@webmonkey StudioPress doesn't visit the forum that often. You might want to copy/paste your response here and send it in their contact form. Join up on the Genesis Slack. You'll land in the General Channel, and there is a Contributor channel. I'll watch for you.
Need help with customization or troubleshooting? Reach out to me.
January 6, 2020 at 1:17 am #495819Brad DaltonParticipantAnother option is to use a custom search.php file with code to remove the content and add back the featured image.
January 6, 2020 at 5:41 pm #495823webmonkeyMemberThanks Anita, I have done that.
braddalton, it's working on the Category and Tags archives just fine. Why wouldn't it also work on Search? It used to in the current iteration of the site.
January 6, 2020 at 6:32 pm #495824AnitaCKeymaster@webmonkey I just did a test on a demo I have. I copied the
search.php
file out of Genesis and placed it in the theme folder. I then took my markup of how I wanted to see the search results and added it to thesearch.php
file. When I did that, it work nicely.Try doing that.
Need help with customization or troubleshooting? Reach out to me.
January 7, 2020 at 1:32 am #495828Brad DaltonParticipant@webmonkey Would need to see your entire code however it works perfectly when i test it at my end.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.