"wp-query" ambiguously refers to one of two things. 1) WP_Query is a class native to Wordpress which allows users to query the posts database using a number of criteria. 2) $wp_query is the default object that holds the main query object on each WordPress page.

learn more… | top users | synonyms

0
votes
1answer
33 views

Modifing archive query affects show post count function

I'm trying to modify the archive query of archive page with this function hooked to pre_get_posts action hook. // Load our function when hook is set add_action( 'pre_get_posts', ...
0
votes
1answer
65 views

Custom post type and custom taxonomies display

I have the following CPT and Taxonomy in my WP: CPT: magazine Hierarchical: true Has Archive: true Custom Taxonomy: authorname (Magazine Author. Not the same as WP Author) Attached to: CPT ...
0
votes
1answer
3k views

WP_Query class not found

The idea is simple. I have a drop-down menu generated with get_categories(). This outputs a list of categories in an unordered list, each in it's own li element. I'm getting the text values of those ...
0
votes
0answers
48 views

Pagination on page.php with wp_query and query_posts

I'm trying to get pagination to work on a custom page.php and this has been kicking my butt... here is my site Here is my code: <!-- Page Blog Body Start ...
0
votes
0answers
31 views

pagination not working on page template

I am having a custom page for displaying community posts, where i want to display the posts posted in last 30 days sorted in desc order by meta value of post views which has to be greater than ...
0
votes
1answer
4k views

Get the number of rows from $wpdb->get_results not working

I want to count the number of rows of this custom wordpress query and it does not work: *PS I am accessing a custom table inside my wordpress database, mabe by myself. The $wpdb->get_results part ...
0
votes
0answers
32 views

WP_Query search by meta tags shows all results everytime

I'm using a search form with WP_Query to refine results of some custom post type. It's working well if I search by items but not with text input with . It shows all results: Code for the search ...
0
votes
1answer
38 views

WP_Query - Accessing MetaValue from Query Result

Have this code. In doing a var_dump the meta_value is being retrieved under public object meta_value. I'm trying to access this data in a "WordPress" away instead of a more traditional PHP way. What ...
0
votes
1answer
67 views

Get pagination working for custom loops within page templates

I've got a custom loop for which I'd like pagination. The codex and examples I've found online indicate that I should get pagination as long as I pass the 'paged' query variable into the loop as the ...
0
votes
1answer
82 views

WP_Query based on URL parameters

I'm looking for some help in creating a query based on fields I made in Advanced Custom Fields. I'd like to create a query that would loop through a custom post type, using arguments such as: ...
0
votes
1answer
33 views

Adding a parameter to the default query

I'm using ACF to create a "Featured" post section of the index.php and I'm having trouble then excluding that post from the main query. <?php $tmp = $posts; $isPaged = ...
2
votes
1answer
142 views

Changing Posts Per Page and offset with pre_get_posts

I have a filter using pre_get_posts to change the number of posts per page from 4 on the news landing page to 8 on all other pages (page 2, 3, etc). However I don't seem to have got the offset ...
-1
votes
1answer
455 views

query_posts different amount of posts per page [duplicate]

I have a posts_per_page query to paginate multiple post types, which works great! Now though, as it paginates it to show (in this case) 100 posts per page, I'm wondering if you can show 100 on page ...
0
votes
0answers
57 views

How to query and group posts by category?

/* * Loop through Categories and Display Posts within */ $post_type = 'post'; // Get all the taxonomies for this post type $taxonomies = get_object_taxonomies( array( ...
0
votes
1answer
34 views

How to add multiple custom URL variables?

I am building a Wordpress plugin that looks for different custom variables in the URL. The way I am able to achieve that right now is with this code: function add_custom_query_var( $vars){ ...
0
votes
1answer
56 views

Using tax_query to get single post per category

I have a list of magazines I need to categorize and sort. I have created a custom post type and registered a custom taxonomy to organize them. Category Structure: Print Magazines (parent category) ...
2
votes
1answer
121 views

How to bring specific post to front of wordpress loop?

So, I have a WordPress loop going on. The below code is the template page for the woocommerce product archive page. Here's the use case for what I am trying to find out how to achieve: User is ...
0
votes
1answer
41 views

Creating a Tabbed Widget

I have setup my widget to retrieve data from custom post types. I am using WP Query to show the data, but it still not showing. I have also setup the file in a gist for easier lookup ...
2
votes
2answers
194 views

Conditional to modify query results

I'll admit, I'm not a PHP expert, nor am I familiar with all of the WordPress functions and hooks. I've been stuck on an issue, searching for help without much success, and I was hoping that someone ...
0
votes
1answer
27 views

WP_Query for CPT with filter by another WP_Query

I'm working on a project have 2 CPTs: Projects Units Every Unit has a meta value containining the id of Project Every Project is assigned a custom taxonomy named Regions Now I need get all Units ...
0
votes
1answer
22 views

Sort / Filter Queries

I'm working on a website, that showcases products, and now I'm working on the query part. Basically I want to have one page, that displays a list of products as a normal query, and then on top of the ...
1
vote
1answer
60 views

All sticky posts are returned in custom query

I have the following code: $recommended_args = array( 'post_type' => 'post', 'posts_per_page' => 3, 'post__in' => get_option('sticky_posts'), ...
0
votes
0answers
24 views

Trending Tags based on post views

I'm looking to display a list of the most trending tags on my wordpress blog - based on views that the posts within these tags have had, with a max tag count of around 10. I've looked into the ...
0
votes
0answers
85 views

Filtering loop by query string in select option (custom field)

I'm trying to filter out some posts on a page template by a custom field. I could be attempting to solve this problem the wrong way - but I think a query string would be best here. Please advice if ...
0
votes
1answer
21 views

Archive - Show Page Month Headers

Trying to output posts on an archive page with date titles. Ideally this can be a single query so I can paginate the archive. Currently I can call multiple queries for each date item but I don't think ...
0
votes
1answer
36 views

Custom loop - Isolating post meta output depending on current query taxonomy terms

I have started constructing is a page to display a series of products based on certain criteria. Each product is part of two separate taxonomies, one for brand and one for product size (each product ...
0
votes
1answer
48 views

WP_Query with offset and 'orderby' => 'rand', offset not working

I have the following situation: on my index.php I am showing the most recent 20 posts using WP_Query(). On the same page in another section I would like to display 3 more random posts from the archive ...
1
vote
1answer
70 views

Duplicates with WP_Query loop

I'm showing on my front page only posts with featured image. My problem is that on every next page load I receive the same results aka getting duplicates. I'm using ordering by custom field. Any ...
0
votes
1answer
95 views

WP_Query with custom post type search showing all results every time

I'm working on building a search form for some custom post type. Problem is, the search yields the same results every time, which is all posts of that custom type. Please advice: Code: Search form: ...
0
votes
3answers
97 views

Using WP_Query in “parse_query” or “pre_get_post” in Posts2Posts

UPDATE: The hook is working with "classic" Wordpress filter (like post__in), so it's probably a Posts2Posts issue. I'm still looking for suggestions if someone has any idea. ORIGINAL POST I'm ...
1
vote
1answer
67 views

Display only posts with thumbnail using WP_Query

I'm having hard times with showing only posts which have featured images using the loop. My PHP level is basic and any help will be really useful. So basically this is my original code : if( ...
0
votes
0answers
90 views

Add search box in Bootstrap slider carousel

I'm using the Wordpress theme 'evolve' which uses a Bootstrap slider on the front page with a 'Learn More' button on it. How do I add a search box instead of the 'learn more' button which will ...
0
votes
2answers
117 views

When WP_Query only returns 1 post, how do I automatically redirect to that post?

I've been searching around for a few hours now and can't figure out how to do this. Seems really simple. I've seen lots of redundant examples on how to redirect to a single post when a search result ...
0
votes
0answers
56 views

423 queries in 6.098 seconds

For a few months now, i'm facing a lot of difficulties with one of my websites being too slow and i'm guessing the reason behind this could be the number of queries. At the moment these are the ...
241
votes
7answers
86k views

When should you use WP_Query vs query_posts() vs get_posts()?

It seems like half the tutorials in the Codex and around the blogosphere use query_posts() and half use WP_Query. What's the deal?
2
votes
2answers
66 views

Select random post every day

I am looking for a script to select 1 random post per day in Wordpress. I found the code below, but this keeps gathering a new post every time I refresh the page: <?php function ...
0
votes
2answers
50 views

How do I check if there is a tag in the title

I have many post with multiple tags ex: AMOS LEE, FOO FIGHTERS,TAYLOR SWIFT Post only have one of the tags in the title ex: “The Man Who Wants You” – Amos Lee How would I scan the_title() and go ...
0
votes
1answer
22 views

Weird Behaviour: Not all Wordpress Posts appearing

My wordpress posts have vanished on my dashboard but remain in the database? Meaning I have many 404 errors. All (52) | Published (4) | Drafts (7) | Trash (2) TOTAL =11 items (Note how theres only ...
1
vote
1answer
40 views

Targeting specific pages in the loop

I am having a custom query that calls in pages in an array like so: <?php $args = array( 'post__in' => array( 2, 7, 9, 11, 13 , 15, 17 ), 'post_type' => 'page', 'orderby' => ...
3
votes
3answers
7k views

Pagination with custom SQL query

I have my own SQL string to select Custom Post Type posts with specific WHERE clause. I've used the offset and limit to return appropriate posts depending on a page being displayed. That's working ...
0
votes
1answer
34 views

Search format not matching taxonomy query

I have inherited some code in this project. This search works. I can click on each individual taxonomy and see the results displayed on my page. However, I would like this to extend the search rather ...
0
votes
0answers
22 views

/page/2/ not showing

I am having a weird issue where when clicking on the pagination links the page just refreshes. The links are pointing to the proper pages(/page/2/) but when clicked, they do not show in the url. This ...
0
votes
1answer
50 views

Using get_term_by to get tag id

I want to get posts that do not have a certain tag. I am having trouble retrieving the tag-id. The term id comes up as 0. Here is my code: $tag_name = 'my-sticky'; $tag = get_term_by( 'name', ...
0
votes
1answer
61 views

option select form always deleting the sql query

I have this form: <tr class="user-statusz-wrap"> <th><label for="statusz"><?php _e('Státusz') ?></label></th> <td> <select type="text" ...
0
votes
0answers
30 views

WP Query - Group by relation (custom post type)

I have a custom post type Office. An office has an address, email, ... . An office also has a relation with a custom post type Region. So an Office must have a relation with a relation with one ...
0
votes
1answer
55 views

WP_Query inside an existing wp_query stops next post showing

I have a query that is showing the 5 latest posts on my homepage from the blog. After the second post I have added a div #more-news then the posts carry on in order after this. This was all working ...
0
votes
1answer
33 views

Create query for both custom post type and category

I have a custom post type called articles and have category = news I want to make a query from the two parts to get content from (cpt=articles, category=news) in the same query? How can I achieve ...
0
votes
0answers
28 views

Restrict a query for custom field

I am using a plug in, which stores tickets as posts (Awesome Support Plugin) in the plugin classes, there is a function to restrict the tickets loading in the admin panel, basically to show tickets ...
0
votes
0answers
36 views

How to filter Wordpress menu by tag name of the post

I have a simple wordpress theme installed on my server. The url is : http://urhalpool.com/wp/ I have used tagging against my post and those post added to my top and left menu. When I am filtering by ...
1
vote
1answer
55 views

WP_Query returning no results

I have the following code to merge 3 different queries: <div class="features-list"> <?php $args1 = array ( 'post_type' => 'page', ...