- This topic has 3 replies, 3 voices, and was last updated 1 year ago by
Leo.
-
AuthorPosts
-
April 8, 2020 at 2:52 pm #1231820
Hilton
Hello,
I would like to know how I can display thumbnails next to recent posts in the side widget? https://prnt.sc/rvpgb2
And I’d like also to know how can I create a widget to display the last X posts from a specific tag (nowadays I am using WP Show Posts, but I think that it would be better if I could use a widget from the theme, just like Recent Articles)
Thanks
April 8, 2020 at 3:18 pm #1231841David
StaffCustomer SupportHi there,
unfortunately the Recent Posts widget that is built into WordPress doesn’t have thumbnails.
This Plugin provides that:https://en-gb.wordpress.org/plugins/recent-posts-widget-with-thumbnails/
WP Show Posts is created by the same author as GeneratePress. And is still the best way to do what you require.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 8, 2020 at 3:41 pm #1231857Hilton
Hi David,
I’d like to do it without having to install a new plugin.
I’ve achieved a nice result with this code below, but I am unable to customise CSS.
function wpcat_postsbytag() { // the query $the_query = new WP_Query( array( 'tag' => 'bombando-na-web', 'posts_per_page' => 6 ) ); // The Loop if ( $the_query->have_posts() ) { $string .= '<ul class="postsbytag widget_recent_entries">'; while ( $the_query->have_posts() ) { $the_query->the_post(); if ( has_post_thumbnail() ) { $string .= '<li>'; $string .= '<a href="' . get_the_permalink() .'" rel="bookmark">' . get_the_post_thumbnail($post_id, array( 50, 50) ) . get_the_title() .'</a></li>'; } else { // if no featured image is found $string .= '<li><a href="' . get_the_permalink() .'" rel="bookmark">' . get_the_title() .'</a></li>'; } } } else { // no posts found } $string .= '</ul>'; return $string; /* Restore original Post Data */ wp_reset_postdata(); } // Add a shortcode add_shortcode('categorytags', 'wpcat_postsbytag'); // Enable shortcodes in text widgets add_filter('widget_text', 'do_shortcode');
April 8, 2020 at 4:43 pm #1231920Leo
StaffCustomer SupportWe can’t really help with CSS for a custom solution as it’s not GP related at all.
Do you see a big speed difference when using your code vs the plugin David suggested?
We’ve had pretty good experience with that plugin.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.