The post loop doesn’t work
Go to admin (WordPress Portal) > Settings > Reading, look to “Front page displays” and make sure “Your latest posts” is checked https://codex.wordpress.org/Settings_Reading_Screen
Go to admin (WordPress Portal) > Settings > Reading, look to “Front page displays” and make sure “Your latest posts” is checked https://codex.wordpress.org/Settings_Reading_Screen
This was answered in a previous question: https://stackoverflow.com/questions/31434373/in-wordpress-how-do-i-set-the-default-admin-sort-order-for-a-custom-post-type-t#answer-31520570 This accepted answer will walk you through how to set up the pre_get_posts callback. That would be my recommendation.
You are confusing things a bit, these are post formats, not post types. Formats are a native taxonomy, not a post type. As any taxonomy its primary (and only) functionality is to organize posts in logical groups. Formats don’t do anything on top of that. You need to implement yourself any and all functionality you … Read more
Initialize an array before the first loop: $exclude = array(); Then add the ID of each post within the first loop to that array: while ($query->have_posts()) { $query->the_post(); $exclude[] = get_the_ID(); // etc… Then use that array to exclude those IDs via post__not_in in the second query: $args = array( ‘post_type’ => ‘page’, ‘post__not_in’ => … Read more
Here’s a solution using a [shortcode] which doesn’t rely on running PHP inside of the content area. Here are the docs for get_post_meta() which show how that function should be called. add_shortcode( ‘buy_status’, ‘wpse249289_buy_status’ ); function wpse249289_buy_status( $atts ) { $output=””; if ( ! get_post_meta( get_the_ID(), ‘buy_status’, true ) ) { // Post meta value … Read more
There are several approaches to your issue. 1- Getting the original author inside a loop To retrieve the original author of a post inside a loop, you can use get_the_author(); to get the username of the author or $post->post_author(); to get his/her user id. If you wish to get the revisor’s username or id, you … Read more
Try this: <?php $thePostIdArray = array(“11”, “13”, “15”, “17”, “19”); $limit = 5; $query=new WP_Query(array(‘post__in’=>$thePostIdArray)); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); $counter++; if ( $counter < $limit + 1 ) : $post_id = $thePostIdArray[$counter-1]; $queried_post = get_post($post_id); ?> <a href=”https://wordpress.stackexchange.com/applications”> <div class=”col-md-5 apps text-center”> <?php the_post_thumbnail(‘full’, array( ‘class’ => ‘img-responsive’ … Read more
I believe this should work in all cases – whether you are in the loop or not. (In a widget, chances are you are not in the loop) Mind you, outside the loop, this will work very well on single pages or posts, but might not display the post you want on other types of … Read more
Take a look at WordPress codex for WP_Query for more information. You’ll see there are different parameters for WP_Query, you just need to add the posts_per_page parameter with the value set to -1 to show all posts. $products_IDs = new WP_Query( array( ‘post_type’ => ‘product’, ‘posts_per_page’ => -1, )); while ($products_IDs->have_posts() ) : $products_IDs->the_post(); // … Read more
You could get the posts by slug instead of name. Like this: $posts = get_posts(array( ‘post_type’ => ‘coupon’, ‘numberposts’ => -1, ‘post_status’ => array(‘publish’, ‘unreliable’, ‘draft’), ‘tax_query’ => array( array( ‘taxonomy’ => ‘stores’, ‘field’ => ‘slug’, ‘terms’ => array( ‘new-store’ ), ‘include_children’ => false ) ) )); Or you could get the posts by term … Read more