How can I show second most recent post in sidebar, if most recent post is open in the browser?

You can use the WP Query option “post__not_in” for that, this variable should be an array with IDs of posts that should not appear on the result, so you would use it like that: $the_query = new WP_Query(array( ‘post__not_in’ => array( get_the_ID() ), ‘post_type’ => ‘articles’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 1, ‘orderby’ => ‘date’, …

Read more

How to display Most Recently Read 10 Posts by a logged in user in wordpress

At first you need to set a meta value when a post is visited using this way if( is_user_logged_in() ) { update_post_meta( $post_id, ‘post_readed_by’, get_current_user_id() ); } Then you can get the recent visited posts <?php $args = array( ‘posts_per_page’ => 10, ‘meta_key’ => ‘post_readed_by’, ‘meta_value’ => get_current_user_id(), ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ); …

Read more

Recent posts with comment count in “Sidebar” template [closed]

‘;’ is missing in this line echo “<dt>$recent_date &nbsp; / &nbsp; <span class=”comment”><a href=”$recent_link#disqus_thread”>$recent_count</a></span></dt><dd><a href=”$recent_link” title=”$recent_title”>$recent_title</a></dd>” For this reason code is throwing the fatal error. Please replace that line with this code echo “<dt>$recent_date &nbsp; / &nbsp; <span class=”comment”><a href=”$recent_link#disqus_thread”>$recent_count</a></span></dt><dd><a href=”$recent_link” title=”$recent_title”>$recent_title</a></dd>”;

Help with “Recent Posts” Loop that is specific to a topic

Put this in your sidebar template where you want the listing to show up. Alternatively, you could use a plugin that allows you to run php in widgets and then place directly in a widget box, but that’s not always wise. <?php $categories = get_the_category(); $category = $categories[0]; $category_id = $category->cat_ID; $args = array(‘category__in’ => …

Read more

How to display recent posts on home page with title, post date, author and featured image?

The functions you are looking for, are: the_post_thumbnail_url(); // For featured image the_author(); // For author name get_author_posts_url(); // For author link the_date(); // For post’s date So, your code should be something like this: <div class=”cs-post-carousel-layout”> <div class=”cs-container swiper-container”> <div class=”swiper-wrapper”><?php // define query arguments $args = array( ‘posts_per_page’ => 5, // your ‘x’ …

Read more