FAQ Database Discussion Community


Query custom post type with jQuery.load()

javascript,jquery,wordpress,custom-post-type,wp-query
Im working on a site see here and I created a custom post type named "projects". When the page initially loads, Everything works fine, all the post data is loaded. But when I use $.load() to load the same code from an external file nothing gets displayed. It only appears...

trying to retrive a post_type with custom fields and media query

wordpress,advanced-custom-fields,wp-query
Well, I've a created a post type with several custom fields (with ACF) and now I need to retrive the custom post_type by one of it's custom fields, that has an array as the meta_value, this is the code that I'm using to get the custom post_type $args = array(...

Exclude category Wordpress (WP_Query not working)

php,wordpress,wp-query
Could anyone explain why this query isn't working? I want to exclude the posts tagged with homepage. It still shows the post with category name 'homepage'... <?php $query = new WP_Query( 'category_name=-homepage'); ?> <?php if ( $query->have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part(...

How to exclude posts without featured images from custom post type WP_Query

wordpress,wp-query
We have the following WP_Query which collects all custom posts (except id=191) and lists them randomly: $args_projekte = array( 'post_type' => 'projekt', 'posts_per_page' => 18, 'post__not_in' => array(191), 'orderby' => 'rand', ); $query_projekte = new WP_Query($args_projekte); How do we extend this to ALSO exclude all posts WITHOUT featured images? Thanks...

Return all args used in query_posts for use in another WP_Query

wordpress,woocommerce,wp-query
I'd like to grab all the args that were passed to the original query_posts (main loop) and be able to modify them for use in another secondary loop. For example, if the main loop passed a whole bunch of args, I'd like to grab them all, modify one of the...

Order or orderby not working in WP_Query when you are in category page

wordpress,wp-query
I have the next WP_Query in footer.php in my wordpress: wp_reset_postdata(); $argsLast = array( 'post_type' => 'post', 'posts_per_page' => 3, 'orderby' => 'date', 'order' => 'DESC', 'category__not_in' => array(193,189,192,195,207,190,213), ); $ultimosposts = new WP_Query( $argsLast ); And it works fine in all pages of my wordpress except the category pages....

Querying sanatized data with meta_query in Wordpress

php,mysql,wordpress,wp-query
After Googeling this for a while, I've found that this should work ref., but I don't seem to get it running. On the backend I have a custom field on commments for setting a list of userIDs of who liked it. It is stored sanatized in the DB this way:...

Search Functionality broken by the wp 4.2 update

php,wordpress,wp-query
Repost from wordpress.stackexchange: I run a blog site with posts by authors, and I implemented a search that would return results if the search was like an author's name or the search term was contained in a story. I was functioning and properly returned authors who matched the search, but...

wpdb & wp_query order by return wrong values

mysql,database,wordpress,wpdb,wp-query
i wanna get results from wp_postmeta order by DESC their values.i use this codes : $top_query = $wpdb->get_results("SELECT meta_value FROM wp_postmeta WHERE meta_key = 'sd_top_numbers' ORDER BY meta_value DESC"); foreach ($top_query as $details) { echo $details->meta_value; echo '<br/>'; } output! 8800 8900 9600 9700 15700 16200 i also try wp_query...

WPML: wp_query() returns posts in all languages rather than just current one

wp-query,wpml
No matter whether I use it from my page in French version or in English version, wp_query() returns my custom post types in all languages, not just in the current one. Get_posts() does the same thing too. When I visit my page in French, I want them to return CPTs...

combine keyword search and tax query in wp_query

php,sql,wordpress,wp-query
I've been trying to create a custom search query, and I've made some progress on it, but have hit another roadbump. I'm trying to combine the meta_query, keyword search ('s') and tax_query in a wp_query with an 'OR' relationship. I've gotten the meta_query and 's' to work together thanks to...

Wordpress WP_Query Multiple Queries

mysql,wordpress,wp-query
I'm trying to come up with a way of querying a CPT by a specific author but also if a meta_key has a specific value. For example, my CPT has an author ID attached to it as well as a 'recipient' custom field. What i need is all posts of...

How to add permalink into WP_Query in Wordpress Theme

php,wordpress,permalinks,wp-query
I want to add Blog Page in front-page.php.I want to show only post title with link to actual post.I dont know where to put the_permalink in my code.My code like below: <div class="profile"> <?php $query = new WP_query( 'pagename=blog' ); if ( $query->have_posts() ) { while ( $query->have_posts() ){ $query->the_post();...

Wordpress WP_Query not using keyword from url query value?

php,wordpress,wp-query
I'm using a form to change the values in a WP_Query on a custom post type. I have 2 select fields using taxonomy values, and a keyword search. The select fields are working fine, however the keyword doesn't affect the query (although it shows up in the url query string)....

How to get post id from attachment wordpress

php,wordpress,while-loop,wp-query
I'm using below code to get all the attachments assign to my custom post type..but now i want to get the post id within the loop..how can i do that?? $query = new WP_Query( array( 'post_type' => 'portfolio', // adjust your custom post type name here 'posts_per_page' => -1, 'fields'...

How to Query Posts if Post Meta Value is multidimensional array?

wordpress,wp-query
I was using the following meta Query, but I'm still getting irrelevant posts. $current_query['meta_query'] = array( array( 'key' => '_game_selected_platforms', 'value' => $platform->term_id, 'compare' => 'LIKE' ), ); Whereas the meta value was multidimensional array as follows: get_post_meta('$postID','_game_selected_platforms',false); ...

WP_Query returns no results

php,wordpress,wp-query
I am trying to retrieve some pages in wordpress using WP_Query and some arguments: $args = array( 'post_type' => 'posttype', 'posts_per_page' => 24, 'post__in' => $store_ids, 'paged' => $paged, 'post_status' => 'publish', ); $the_query = new WP_Query( $args ); The pages I'm trying to retrieve here should match an ID...

Creating complex queries with WP_Query in Wordpress

wordpress,wp-query
Here's a complex query which we've built using WP_Query. It should: Ignore post id 191 AND Select all posts with 'reihenfolge' <= 18 AND Ignore posts without a featured image AND Order them randomly Here is the code: $args_projekte = array( 'post_type' => 'projekt', 'posts_per_page' => 18, 'meta_query' => array('relation'...

Wordpress Query posts that have title > another title

wordpress,wp-query
I am trying to make a query of a custom post type that searches the next 3 posts alphabetical order after a specific title. A snippet of the arguments to wp_query() is $vars = array('paged' => $page, 'posts_per_page' => intval($posts), 'order' => 'asc', 'offset' => ($offset ? $offset : ''),...

fetch products if image is found in woocommerce?

wordpress,woocommerce,wp-query
i want to show image only products in woocommerce. My fetch query is given below $args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 9, 'orderby' =>'date','orderby' => 'rand' ); $loop = new WP_Query( $args ); how can i get the image products only?...