"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
3answers
423 views

shortcode using multiple WP_Query's with multiple category names not fully functional

we're working on a bilingual site, Larry A. Downs all the posts are categorized into two categories, english or spanish, along with other categories. so every post has multiple categories, i've ...
0
votes
0answers
27 views

Wordpress query vars are not added

I'm currently trying to figure out how to get my custom url rewrites working (WP Rewrite the last two parts of the URL), while doing this I came across the following problem: I have made a custom ...
2
votes
2answers
81 views

How can i get the last post from wp multisite?

I have to get the last post from my Multisite network on WordPress. For now I use this code for display the last updated post after a cycle on each blog_id: <?php $blogs = get_last_updated(' ', ...
0
votes
1answer
31 views

Does query_posts have an effect on get_the_category?

I am having trouble debugging a situation, and I think some better background information on how these systems work would be very helpful. I know that the use of the function query_posts is strongly ...
0
votes
0answers
22 views

Sort posts in dashboard using custom field; also include posts where field isn't set

I'm using a pre_get_posts filter found on this question thread here, to sort a custom post type in the dashboard: function xyz_event_sort_order( $wp_query ) { if ( is_admin() ) { ...
0
votes
1answer
51 views

Show custom post type filtered by category

I would like to have a custom post type which contain several sliders for showing in each category page (exact category.php), one for each as planned. All sliders were assigned to related category. ...
0
votes
1answer
53 views

Merge 2 args in one WP_Query and order it by date

I'm trying to merge 2 WP_Query in a new WP_Query and then order all posts in this new merged query by date descending. I can merge 2 WP_Query and work fine, but I can't order the new query $args1 ...
0
votes
0answers
32 views

Orderby custom date fields with meta_query broken on OR relation

I have an 'event' post type that has custom start and end date fields. In a block on the home page, I'm trying to show only upcoming or ongoing events. So, to achieve this, I'm doing a meta_query that ...
0
votes
1answer
36 views

Passing conditional arrays to WP_Query() [closed]

I've looked around at a few places and could not find an answer. I was wondering what the best way to create a WP_query from possibly empty variables were. I have about 16 of these $_GET variables. ...
0
votes
1answer
42 views

Second loop pagination changes URL, not content

I'm reasonably new to WordPress and I believe I am missing something conceptual here. I have assigned a static post to be my front page. My front-page.php template begins with a standard loop: ...
0
votes
0answers
33 views

How to add archives (with pagination) to page template?

So the site I'm building has a few different archives pages. For the newest one I'm building, I tried to copy the archive.php I've got: page-archives.php: <?php get_header(); ?> <section ...
7
votes
4answers
4k views

Broken? WP_Query and “attachment” as a post type

I have a gallery attached to a page. On that page, I'm running the following query: $events_gallery = new WP_Query( // Start a new query for our videos array( 'post_parent' => $post->ID, // ...
0
votes
1answer
49 views

Displaying content to search engines but via navigation only for registered users.

Displaying certain information depending on if a user is registered is quite easy as I have been using this code <?php if (current_user_can(‘subscriber’)) { ?> [content here] <?php } ...
0
votes
0answers
21 views

how a query can use local parameters in plugin function?

I've wanted to add a custom post type, so i've done a plugin to put on/off this post type. i have widgets inside the plugin in order to print posts with this custom type, that call more or less a ...
0
votes
2answers
54 views

WP_Query of Category Not Showing First Post

I have the following loop, and only this loop, in my home.php file (apologies if I didn't paste the code properly). I have populated lorem ipsum posts, and noticed that of the five posts only four ...
0
votes
0answers
28 views

Custom WP_Query with SQL directives for getting posts by authors and terms

I am making a custom page where I need to display posts from authors and terms (categories). I tried with the built in WP_query arguments but I am not getting the result I want. So I want to know how ...
0
votes
3answers
97 views

ACF: post query, hide duplicate values

I'm querying an ACF field, and displaying all the results on the front-end like so— PHP: <ul class="category-menu-items"> <?php // args ...
0
votes
0answers
22 views

What is the best way and how do I display posts from categories and users a user is following?

I am making a user/term following system where users can follow users and terms (inlcuding categories). Once the user follows another user and/or term I am saving the ids for each in a custom table. ...
0
votes
1answer
51 views

Randomly select one of last 3 posts

ok so i have this: $args=array( 'orderby' => 'rand', 'order' => 'DESC', 'posts_per_page' => 1, 'offset' => $offset, ); $q = new ...
0
votes
0answers
21 views

Trying to do a custom Search results page. Failing when I use the pagination

I'm trying to do a page where the user can search for posts with a Keyword (as search.php) and post date filter (between one date and another). I have a form with 3 fields: keyword, date1 and date2 ...
-1
votes
1answer
145 views

How to query posts from specific authors and categories using WP_query?

I currently have a WP_query where I am getting posts from a specific set of authors. To this, I want to add specific categories as well. $args = array( 'author__in' => $authors, 'posts_per_page' ...
0
votes
0answers
26 views

Post OrderBy slow performance

I have been struggling for quite a while now with this, to put in simple term here is what i do. I do an OrderBy with wp_postmeta information This allow me to give an additional date to play with. ...
0
votes
0answers
23 views

Query custom post type by date field only working when two posts match the query

Hi I am trying to query a custom post by an advanced custom field that is a date field and this is how it is registered in a plugin that I have created to take care of all non-visual aspects of the ...
0
votes
1answer
20 views

How can I pull information from my loop and divide them seperately?

I've created a Custom Post Type that I'm trying to implement into a CSS slider. To do this I've created a custom template and added counters to get unique ID's for every new post that get's pulled. ...
0
votes
0answers
45 views

Pagination for blog posts reloading same page

Symptoms Visiting /blog/ loads the first 10 posts, as expected. Visiting /blog/page/2/ (and onward) loads the new URL but with the same 10 posts. Nothing changes but the URL. Setup Details Custom ...
0
votes
0answers
20 views

how i can make recursive wp_query and work

What i have done so far is: on single post page i have a box with 3 recent posts, i use WP_Query and reset with wp_reset_postdata(); i have made a shortcode that displays recent posts, i use ...
0
votes
0answers
11 views

WP_Query & posts_per_page [duplicate]

I have created a custom loop with WP_Query and I am trying to display only 4 posts. I do not need pagination or anything similar. Just the four posts. I am using posts_per_page => 4 to do this, but ...
0
votes
2answers
51 views

Order posts with custom taxonomy array

I am trying to make my loop go through the posts that are associated with these terms. Currently nothing is being output. <?php $args = array( 'post_type' => 'staff', ...
1
vote
0answers
29 views

echo a specific meta_key queried through a custom post

I'm new to coding but love tinkering around (on Virtual Server) with bits to upgrade my current website when I have the time. What would be really useful to me would be to post an individual ...
0
votes
2answers
39 views

How to get Tags with specific post id

I have created one post and post ID is 34 and added some Tags and Now I want to retrieve all tags with post ID. Any Idea?
0
votes
0answers
50 views

Filter plugin posts by meta value

I am a WordPress beginner, but have a few years of software development experience. I have a WordPress plugin used to display custom data via a custom post type. The index page contains something ...
4
votes
1answer
89 views

How do you get the count of posts in an archive page?

I have a custom posts archive page of the type archive-my_custom_post_type.php and I am using the "standard" loop which consists of the ever-so famous <?php if(have_posts()) : ?> <?php ...
0
votes
1answer
57 views

Custom post type blog pagination conflict

I have a custom post type called 'emp_case-studies' and it has a page archive. Here is the code for archive-emp_case-studies.php: <?php $blog = $wp_query; $wp_query= null; $args= null; ...
2
votes
1answer
117 views

How to make a WP_Query search with custom post types?

I've registered a custom post type called "node". When I create a basic WP_Query to get posts of that type, it works just fine. Example: $args = array( 'post_status' => 'publish', 'post_type' ...
0
votes
1answer
32 views

query post based on comparison

Each post in my site can be rated as 'good' , 'ok' , 'bad'. The values are stored in custom fields. I now need to show top 10 posts with maximum 'good' and it should not display posts with greater ...
0
votes
1answer
99 views

Display count number of posts with the same specific meta_key meta_value

I want to display a list of posts ordered by a specific meta_key. My posts have the following custom fields: author_lastname and author_firstname. So far, it works good. The posts are displayed ...
0
votes
0answers
15 views

How to get from a query an array of post names of a particular custom post type? [duplicate]

I need to get an array of post names (not titles) of a particular custom post type from a query. How to do this? My query: $query = new WP_Query( array( 'post_type' => 'fpps', 'post_status' => ...
0
votes
2answers
142 views

Prevent pre_get_posts filter on specific post type

I am running into one issue with pre_get_post filter. Actually I have 4 post types. Post, Pages, Events, and Venue. I created one custom field called city for event and venue post type. When ...
0
votes
1answer
84 views

posts_per_page is not working

I have a query to display custom post type categories' posts, but I want to limit the posts_per_page to 8, so I am using the code below. Please tell me, if I'm doing something wrong. <?php $args ...
0
votes
0answers
12 views

Get posts from similar time as current post

Hi guys I've been struggling with this for a while and wondered how you lovely people would go about implementing it. I would like to show 4 posts that were posted before and after the current post. ...
1
vote
1answer
38 views

How to ensure “the_content” filter runs only for the main displayed content?

I have a plugin which adds the method to "the_content" filter. add_filter('the_content', 'myFilteringFunction', 10000); Within that function I want to add some links on the beginning and the end of ...
7
votes
6answers
9k views

Wp get all the sub pages of the parent using wp query

Here is my code $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page','post_parent'=>$parid,'orderby'=>'title','order'=>'ASC' )); It displays ...
1
vote
0answers
272 views

How to filter a query by multiple meta keys and order by other meta keys

I'm trying to query posts using WP_Query and meta_query parameters: $args = array( 'post_type' => 'produkty', 'meta_query' => array( 'relation' => 'AND', array( ...
0
votes
0answers
26 views

Archive by months with pretty url?

I wanted to able to get the archive months working, I tried this http://codex.wordpress.org/Function_Reference/wp_get_archives#Last_Twelve_Months but it only gets the last 12 months, what I wanted ...
0
votes
2answers
67 views

Highlight current post title on a page

In my menu I have a page that is called Campaign. When the user enters to Campaign the page displays the last custom post type of campaign-post. In the sidebar of Campaign page, I'm displaying a ...
0
votes
0answers
49 views

Query posts filter not working

I have created one custom post type which name is villa. In this post type I have added five post and assigned custom field values(mention bellow): Post Name Assigned Fields 1. Chalet ...
0
votes
1answer
60 views

Wordpress Numeric Pagination with Query String [duplicate]

So I have a dynamic loop which is affected by a query sting in the URL.. For example I have 3 categories and when they click the category it just adds a query to the URL: <a ...
0
votes
0answers
78 views

wp_update_post not working

I have the following code in a single script to be run one time to fix post names which are empty. // WP_Query arguments $args = array ( 'post_type' => 'books', ...
0
votes
0answers
28 views

Problem accessing values from $wp_query in plugin

I am creating a custom plugin where I am passing parameters in the url and trying to access the values of those parameters using $wp_query directly in the plugin, but it returns an empty array. I ...
0
votes
3answers
28 views

Query Vars Not Set in Main Query

I have a function that checks page specific and global settings to determine a class related to sidebars. I call the function from the archive.php template and try to check that post_type is 'post', ...