Home › Forums › Pro Support › Some suggestions (you might already have solutions for?)
Tagged: columns, excerpts, suggestions
- This topic has 12 replies, 4 voices, and was last updated 3 years ago by
Tom.
-
AuthorPosts
-
October 27, 2017 at 5:27 am #2863
Adam
ParticipantHey Tom, recently discovered GeneratePress and am making use of Premium, WP Show Posts and Simple CSS. Your work is great!
I’ve been playing around with WP Show Posts pro and I have a few suggestions that I think would make it much improved:
- Make all the text below an image contained within a div, so that text can all be targeted separately from the image. For instance, this would allow me put a border bottom left and right and no border on the image.
- Custom excerpts: I imagine a lot of people are using this for their homepage and might want to show shortened excerpts. At the moment, mine shows the manual excerpt I’ve set on the post page, which is way too long for the WP Show Posts excerpts. I’d like to be able to set custom excerpts for each post displayed with WP show posts.
- Seamlessly go from three columns to two columns for varying screen sizes: I spent a fair bit of time trying to hack this but eventually gave up. My code is below. I think if it set for three columns, it should step down to two columns as an intermediary before jumping to one. Three looks great on desktop, one looks great on mobile, but on tablet one is too wide and three is too narrow.
/*attempted hack WP show posts for two columns*/ @media (max-width: 800px) { .wp-show-posts-columns .wp-show-posts-single { width: 50%; position:static!important; display: inline-block !important; vertical-align: top; } } @media (max-width: 640px) { .wp-show-posts-columns .wp-show-posts-single { display: block; width: 100%; margin-left: 0 !important; margin-right: 0 !important; } } @media (max-width: 767px) { .wp-show-posts-columns#wpsp-144 { margin-left: -40px !important; } .wp-show-posts-columns#wpsp-144 .wp-show-posts-inner { margin: 0 0 40px 40px!important; } #wpsp-144 { height: auto!important;} }
This worked great until I tried to add more than three posts to WP Show Posts and then I realised my
vertical-align: top;
wasn’t particularly clever!Keep up the good work.
Cheers,
AdamOctober 30, 2017 at 3:04 pm #2876Adam
ParticipantWell after all that I solved my responsive columns by setting the WP Show posts columns to 2 and adding:
@media only screen and (min-width: 800px) { .masonry-brick { width: 33.3%; } }
I’m still really struggling to figure out a way to have different excerpts on WP Show Posts and the blog page though.
October 31, 2017 at 9:32 pm #2884Tom
KeymasterHi Adam,
Thanks for the suggestions! Really appreciate it 🙂
For the excerpts, have you tried setting a custom excerpt length for your post list in the “Content” section?: https://www.screencast.com/t/7eLZC8umz
November 1, 2017 at 1:30 pm #2888Adam
ParticipantHi Tom, thanks 🙂
I’ve tried that but the custom excerpt length doesn’t work when a manual excerpt has been set on the post page as far as I can tell? It just uses the manual excerpt.
Even then, it would leave the WP Show Posts excerpt at a word length that will leave the excerpt ending at mid sentence most of the time, and that I have no control over unless I edit the content of the post to suit the excerpt. Would it be possible to have a WP Show Posts excerpt option box on each post page, that defined a specific custom excerpt for displaying with WP Show Posts?
November 1, 2017 at 2:12 pm #2889Adam
ParticipantI’ve been trying to figure out how I might solve this. I’ve added a custom field to one of my posts page with the key being wpsp_excerpt and the value being what I want the excerpt to be. I’ve been trying to figure out how to change the wpsp_excerpt( $excerpt_length ) so that it would call the custom field key and return the value for use as the excerpt for each post, but I don’t know php at all and keep breaking my site!
Is that something that you could do with a custom code snippet? I’m using the WP Code Snippets plugin.
Cheers,
AdamNovember 1, 2017 at 3:11 pm #2890Adam
ParticipantTo my great surprise, this worked! (I have no idea if this is good code or not, but seems to be working as I want!)
function wpsp_excerpt( ) { global $post; $content = get_post_meta( get_the_ID(), $key = 'wpsp_excerpt', $single = true ); echo $content; }
I had to edit the functions.php file though, as it kept returning fatal error cannot redefine function when I added it to Code Snippets. Is there another way around this so that I can add the fix in Code Snippets instead of editing plugin files?
November 6, 2017 at 11:56 am #2907Tom
KeymasterYea, you could do this:
if ( ! function_exists( 'wpsp_excerpt' ) ) { function wpsp_excerpt( ) { $content = get_post_meta( get_the_ID(), 'wpsp_excerpt', true ); echo $content; } }
Glad you found a solution! 🙂
November 6, 2017 at 3:05 pm #2909Adam
ParticipantThanks Tom that works perfectly.
This is the code I ended up with for anyone with the same problem. Add as a code snippet and set a custom field on your post page with the name ‘wpsp_excerpt’ and the value as your custom excerpt and it will display for WP Show Posts. If nothing is set it will default to the excerpt length you have set.
if ( ! function_exists( 'wpsp_excerpt' ) ) { function wpsp_excerpt( $excerpt_length ) { global $post; if ( get_post_meta( get_the_ID(), $key = 'wpsp_excerpt', $single = true ) ) { $content = get_post_meta( get_the_ID(), $key = 'wpsp_excerpt', $single = true ); } else { $content = wp_trim_words( get_the_content(), $excerpt_length, apply_filters( 'wpsp_ellipses', '...' ) ); } // Strip shortcodes from our content $content = strip_shortcodes( $content ); // Strip URLs from our excerpt (oembeds etc..) $content = preg_replace( '~http(s)?://[^\s]*~i', '', $content ); // Return our content echo $content; } }
November 8, 2017 at 12:27 am #2912Tom
KeymasterAwesome, thanks for sharing! 🙂
November 13, 2017 at 11:37 am #2947Drew
ParticipantI’m experiencing a similar issue here in that the word limit is not being applied to custom excerpts entered. I’m using Visual Composer layouts on post pages so if I don’t use custom excerpts, WPSP pulls all the VC shortcode stuff before the actual content.
I tried following the above tips but got lost at the final stage via “Add as a code snippet and set a custom field on your post page with the name ‘wpsp_excerpt’ and the value as your custom excerpt and it will display for WP Show Posts.”
There is nothing in the name dropdown labeled ‘wpsp_excerpt’ and I’m unclear on what the actual value should be.
Is there an easier way to go about this?
November 16, 2017 at 6:22 pm #2970Tom
KeymasterYou would need to manually add the
wpsp_excerpt
value to the Custom Fields. Then I believe your actual custom excerpt text would go into the value.Let me know if that helps at all 🙂
September 16, 2020 at 5:07 am #19399Carlo
ParticipantHi Tom,
I am also trying to reduce the lenght of the custom excerpts. If I understand right, with the above solution we can solved it setting a text string for each post in the wpsp_excerpt (a custom field that we have to create). This test string (if exists) will replace the excerpt.
So the steps are:
– create a custom field wpsp_excerpt
– in each post, insert the text we want to replace the excerpt with– Is that correct?
– Does it also work with the excerpt of the woocommerce single products? (it’s crucial to me because i need to manage how the short descriptions of the procuts are shown in wp show posts)
– Dumb question… where I can put that snippet code? (never put snippet codes directly so far, I usually use functions.php) If it could be of any help, I also have generatepress pro. (and happy with that, by the way 🙂Thank you. All the best. Carlo
September 16, 2020 at 3:09 pm #19428Tom
KeymasterHi there,
It should work. Although, I wonder if it would work just to use the regular Excerpt metabox that comes with WP core? From reviewing the above, I’m not sure I see the difference.
-
AuthorPosts
- You must be logged in to reply to this topic.