How to retrieve certain number of images from a wordpress post?
You have to get a post’s attachments: $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => 5, ‘post_parent’ => $post_id, ) );
You have to get a post’s attachments: $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => 5, ‘post_parent’ => $post_id, ) );
[WP_Query][1] provides list of options including [Taxonomy Parameters][2]. You can use the taxonomy parameter to search the posts like: post_type’ => ‘firma’, ‘post_status’ => ‘publish’, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ‘s’ =>$_POST[‘term’], ‘posts_per_page’ =>5 ‘tax_query’ => array( array( ‘taxonomy’ => $_POST[‘term’], ) );
The ultimate answer will be in your server logs, I’m afraid. (You can also turn on debugging in wp-config – sometimes that helps too) But I did notice a few things that hopefully can help you track the issue: <?php // You should not require the $orig_post variable… global $post; // Get the tag ids … Read more
You can try this code to show only post. if(isset($xt_corporate_lite_opt[‘xt_about_page’]) && $xt_corporate_lite_opt[‘xt_about_page’] != ”) { $args = array( ‘post_type’ => ‘post’); $xt_query = new WP_Query($args); if ($xt_query->have_posts()) { while ($xt_query->have_posts()) { $xt_query->the_post(); the_content(); } } wp_reset_postdata(); } if you have any doubt in WP_Query. then you could check this link in detail. https://codex.wordpress.org/Class_Reference/WP_Query
Your question is very unclear (given that you don’t actually ask a question), but there are 2 problems with your code, both of which are corrected below: $args = array ( //’post_type’ => ‘article’, ‘posts_per_page’ => 5, ‘category_name’ => ‘starter’, // changed from ‘category’ to ‘category_name’ ‘meta_query’ => array ( array ( ‘key’ => ‘recommended_article’, … Read more
$meta_query_args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, // Optional, defaults to “AND” array( ‘key’ => ‘_my_custom_key’, ‘value’ => ‘Value I am looking for’, ‘compare’ => ‘=’ ), array( ‘relation’ => ‘AND’, array( ‘key’ => ‘_my_custom_key_2’, ‘value’ => ‘Value I am looking for 2’, ‘compare’ => ‘=’ ), array( ‘key’ => ‘_my_custom_key_3’, ‘value’ => … Read more
A standard WordPress install doesn’t keep track of visits to pages/posts. So without a plugin there’s no way to know which posts/pages are visited most often. As to finding random posts that’s as simple as: $args = array( ‘post_type’ => array( ‘post’, ‘page’, ‘my-custom-post-type’ ) ‘orderby’ => ‘rand’, ); $query = new WP_Query ($args);
As written your question is off-topic, as it is purely SQL-related. However, the following 2 solutions translate it into WP-ese. Solution 1 $args = array ( ‘post_type’ => ‘project’, ‘post_status’ => ‘publish’, ‘s’ => ‘testingsearch’, ‘meta_query’ => array ( ‘relation’ => ‘OR’, ‘project_date’ => array ( ‘key’ => ‘project_date’, ‘compare’ => ‘EXISTS’, ), array ( … Read more
Try this code:: post__in (array) – use post ids. Specify posts to retrieve. ATTENTION If you use sticky posts, they will be included (prepended!) in the posts you retrieve whether you want it or not. <?php $parent = $post->ID; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $query_args = array( ‘post_type’ => ‘page’, ‘post_in’ => array(‘post_id_to_include’), … Read more
You can try this: $options = array(‘post_type’. => ‘product’, ‘post_per_page’ => -1, ‘nopaging’ => true, ) $loop = new WP_Query( $options ); This adds ‘nopaging’ => true,. See Class_Reference/WP_Query#Pagination_Parameters for more info