WP_Query | ‘post_type’ doesn’t work
You have ‘post-type’ in code instead of ‘post_type’
You have ‘post-type’ in code instead of ‘post_type’
Creating and including a template for your custom post type archive is easy, you just need to create a archive-{$post_type}.php template, WordPress will automatically use that template whenever you visit that particular post type’s archive page. Just remember to set the has_archive parameter when registering your post type. As for the taxonomy archive page, you … Read more
the permalink and post title won’t be available until after you’ve run the query. the following should return the last 3 posts from the designated category. the same post is being displayed 3 times because it doesn’t look like you’re setting the permalink or post title from within “the loop” if (!function_exists(‘get_posts_menus’)): function get_posts_menus($category_name, $count) … Read more
You are doing it wrong on many levels here: You should not be using a custom query in place of the main query. Rather use pre_get_posts to alter the main query accordingly. Go back to the main loop and add the following in your functions file or in a custom plugin add_action( ‘pre_get_posts’, function ( … Read more
Technically you can merge things into loop, by manipulating its posts field (such as $wp_query->posts for main query). WP has it in public for visibility and access, as it tends to. However it’s not that common technique, less so if you are considering injecting something that is not actually posts. It is more common for … Read more
Try this in your functions.php file: add_theme_support( ‘post-thumbnails’ ); set_post_thumbnail_size( 200, 200 ); Read More: http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size
What I see is , you are not following WP coding standard. <?= get_the_title(); ?> is not allowed in WP coding standard. Now you are getting only the post and not as per your args provided, this means you have not reset your main WP Query. We can write the above code as : <?php … Read more
Your code example isn’t random though, it’s a fixed offset, based on a week number. As stated this isn’t something that can be expressed in query API I think. You would probably have to keep track of state with something like following algorithm: Query a random post, store its ID Store a date three days … Read more
Have you considered using a more standard loop, like this? I think it might fix your issue #3. $query = new WP_Query( $args ); echo ‘<div class=”home-middle widget-area”>’; echo ‘<h4 class=”widget-title widgettitle”><span>From the Archives</span></h4>’; if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); echo ‘<article class=”post type-post status-publish format-standard has-post-thumbnail entry”>’; echo ‘<a href=”‘ . get_the_permalink() . … 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