0
votes
1answer
21 views

Using get_posts structure for a specific field [on hold]

Situation I have a custom post type named Packs and another custom post type named Hotels. In the Hotels CPT I publish hotels information, like name, amenities and services for many hotels in the ...
0
votes
0answers
26 views

A Depth Like Parameter For “get_posts”

Wordpress has stumped me for the first time in a very long time. I am trying to limit the depth of a get_posts call in my template. I want to get children but limit it to a depth of only 3 as I am ...
0
votes
1answer
31 views

get_post_meta slowing down my page load (in a plugin)

I've been working on this project where I need to load events (custom post type) and a whole bunch of meta data for every event. The problem is that page loading times are getting longer and longer ...
0
votes
1answer
73 views

get_posts works but new wp_query doesn't

I was told that get_posts is a very bad function to use that that making a new WP_query is absolutely better. My problem is that my get_posts code works but when I tried turning it into a WP_query, ...
0
votes
2answers
67 views

Retrieving 3 latest post from each of 5 different custom post types

I have 5 different custom post types. I am showing 15 latest post from them on my home page using following query: $query = new WP_Query( array ( 'posts_per_page' => 15, ...
0
votes
2answers
45 views

Query posts by a type and another type only if post is in specific category

I have a featured post type and a reviews post type. I would like to include reviews of a certain category (I use categories from the posts type) as well. How could query args be crafted? A crude ...
0
votes
0answers
226 views

Why WP_Query in functions.php is not working when get_posts works?

I have following code in my functions.php. When I try to add new post_type (e.g. post,lawyers) it fills excerpt,slug (this affects in permalink structure), other metaboxes from first post of lawyers ...
-1
votes
1answer
137 views

posts_per_page - Repeats only first posts 'post__in' array

This question correlates with a previous question I was able to solve here: http://wordpress.stackexchange.com/a/137929/28389 I am using an array for 'post__in', and I am able to run this no problem. ...
0
votes
0answers
15 views

return custom taxonomy terms in post object

How would I go about returning the custom taxonomies in the post object with WP Query or with get_posts for that matter. yes, I know I can loop over my query and use get_terms or a number of other ...
0
votes
1answer
70 views

Get posts by list of post IDs ordered by those IDs?

I am going to make a "favourite" posts box, but the article id's are stored in another DB so I only get an array of IDs (which are relevant to the WP DB). I think it could be done with get_posts() or ...
0
votes
2answers
63 views

How to properly use Categories with Custom Post Types

I'm really struggling with this... I created a few Custom Post Types, let's say... Books CD's Maps Now I also have a whole bunch of existing categories and some of these would apply to more than ...
0
votes
1answer
85 views

Retrieve latest post by multiple categories with ID

I have the categories listed below in my product post type. Category Name: Test 1 ID: 82 Category Name: Test 2 ID: 83 Category Name: Test 3 ID: 84 Category Name: Test 4 ID: 85 Now I want to ...
0
votes
0answers
63 views

Combining / Merging two queries?

So I am working on an isotope filtered portfolio page that pulls any attachment tagged with the term "digital-interactive". Each attachment is also linked to a custom post_type called "work". On one ...
0
votes
1answer
58 views

get_posts output always same post

I'm trying to output the last (chronologically) 4 posts having the tag (slug) "pp". <ul> <?php $args = array( 'posts_per_page' => 4, 'taxonomy' => 'tag', 'field' => 'slug', 'terms' ...
0
votes
1answer
176 views

How to show more post at a given category?

I need to show more post at the category state (with tag_ID=21), for example, I set the number of post show at homepage is 6, but I want 10 post when archive state, is there any way to add a filter in ...
0
votes
1answer
118 views

Retrieve posts in custom post type and specific taxonomies

I'm struggling with what seems like should be so simple looking at the codex. I have a custom post type, let's call it 'portfolio'. A custom taxonomy for that, let's call it 'clients'. I can use ...
0
votes
1answer
33 views

Search for pages with permalink

I'm searching for posts this way $args = array( 'name' => $permalink, 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => 1 ); $posts = get_posts( $args ); ...
1
vote
0answers
345 views

Get Recent Posts by Date in Multisite

Everything in explanation is about CDTuts I've created a WordPress Network and I want is to get the recent posts from all of the selected subdomain blogs. I need to get the latest All organized by ...
-3
votes
1answer
187 views

Get all posts without tags

I'm working with a tag plugin. Is there a WordPress way to get_posts or query all posts that have no tags?
0
votes
0answers
100 views

show/hide attachments

Is there a way to show/hide attachments in my case images on a post. What I want is to mark an image as "hidden" and then only show it to the admin and hide hidden images from a normal user I know ...
0
votes
2answers
530 views

Use post__in and post__not_in together?

I'm trying to only show posts that a user hasn't seen, like this: $exclude = array(1,2,3); $include = array(3,4,5); $args = array( 'post_type' => 'post', 'post_status' => ...
0
votes
2answers
261 views

Use WP_Query or query_posts() or get_posts() for optimizing a site?

I have read other answers, but I don't understand which is more fast (the best and simple for slow server running)? I have a website with over 1 000 000 hits /day and a slow server with limitations ...
0
votes
1answer
96 views

get_posts always returning the same number of posts = 5

I don't understand why the code below is always displaying the same number of returned post = 5. When I change the $variable value to another post id of a post with an author with another author_id, I ...
0
votes
1answer
301 views

Trying to check and see if a post has a featured image outside of the main loop

I've got a situation where I need to find out if the currently loaded post has a featured image, if it does, I want it to display a different logo than if it doesn't have a featured image associated ...
0
votes
1answer
72 views

“paged” in WP_Query returns 0 posts

If i don't supply a paged value (get the first page), it works. But when i try to get the next page by doing paged => 2 it doesn't find anything even though there are plenty of posts to get. ...
1
vote
1answer
102 views

get_posts - find out if querystring was crap and fallback is used

If we pass a String to functions like get_posts, and that string is not a meaningful querystring (for Example get_posts(' ')), the function returns the results of the default query (the last five ...
0
votes
3answers
308 views

shortcode for recent custom type post

I'm not a coder so I may have done some "coding" crimes, apologies. I've bought a theme who has shortcodes for last posts but not for last "custom post type". So I tried to create last "custom post ...
0
votes
3answers
76 views

Wordpress ultra slow if I click on posts?

I have 5000 posts on my website, which I have uploaded from a CSV file. This all went well and the website is fast on the back-end and frankly on any other page. There is one exception: if I click on ...
0
votes
1answer
3k views

Count posts returned by get_posts in external PHP script

I'm using WP from an external PHP script by including the wp-load.php file. All functions and everything works as expected so far, except one thing: I can't get the $wp_query->found_posts to work ...
0
votes
1answer
199 views

Query specific number of posts for each post type in specific order

This is related to this other question, I tried with get_posts, pre_get_posts, WP_Query and basically every option I could find for 2 days now, no solution yet. The full problem in hand: I have 2 ...
0
votes
1answer
57 views

Specify strict 'order by' in WordPress query

I have a custom post type called Employees where an employee's name is the post_title of each post. I am trying to figure out how I would sort the post_title column by last name. So for instance, if ...
2
votes
2answers
1k views

Why Does get_posts() Return an Empty Set?

I'm writing a custom plugin that is initialized at init. This plugin is trying to query for some custom post types already stored in the DB. Here's my code: $args = array() $myposts = get_posts( ...
0
votes
2answers
600 views

What should I use, get_posts or wp_query for less CPU load?

I have a blog and on the main page are 3 blocks of posts. So, I get these posts with "get_post" and I have 3 similar codes on page: global $post; $args = array( ... ); $myposts = get_posts( $args ); ...
0
votes
1answer
193 views

Why posts array is empty?

I try to get posts that either do not have a custom field set or if set have a value not like a given parameter. Here is my code: $args_included = array( 'numberposts' => 1, ...
0
votes
2answers
299 views

How to query for a page, get data, then query for child pages of that page

Basically, I want to query PARENT for a bunch of custom field data and echo it out. Then, I want to query all of the CHILD pages of that parent and echo out more data. What's the best way to do it? ...
1
vote
1answer
592 views

Help with WP_Query - Too many mySQL queries

I need some kind of help with wp_query. Am I doing something wrong? I am getting a lot of mySQL queries, while building a new theme. My WP_Query is: <?php $args = array( 'post_type' => ...
0
votes
1answer
485 views

get_posts() and global variables

I was reading this post: When should you use WP_Query vs query_posts() vs get_posts()?, which seems to have become the go-to post for understanding the difference between the different functions for ...
1
vote
1answer
232 views

WP_Query() and get_posts() can't handle over a thousand posts?

So I have a search function that just fetch custom posts and return them as a list. function search() { // post query args $args = array( 'post_type' => 'post_type', ...
0
votes
1answer
896 views

get_posts not finding argument: post_name

I am digging up posts with a specific slug: Where $postSlug = 'abc' $args = array( 'post_name' => $postSlug, 'post_type' => 'post', 'post_status' => 'publish' ...
0
votes
2answers
790 views

How to get single post by one author?

I just want to get the most latest posts by an author. I am using get_posts at the moment but I notice it doesn't take an author argument, so how I can I specify my author? $args = array( ...
0
votes
1answer
220 views

get_posts() seemingly ignoring post_type

I am trying to grab posts of post type "leads" (see below for the code I am using) however the query produced (obtained via debug queries) is including the clause 'where post_type in ("leads", ...
3
votes
1answer
2k views

WP_Query vs get_posts

I have read a number of questions on SE regarding these but I still can't figure the exact difference wrt usage. Would it be true to say that I would probably use WP_Query for the majority of ...
0
votes
1answer
155 views

Execute PHP function inside the admin area

I want to ask if there is a hook for executing php inside the admin area, my problem is I'm trying to do the get_posts wordpress function inside a popup frame using the thickbox jQuery plugin, using ...
1
vote
2answers
92 views

How do you Query posts with nothing in common?

We can get multiple posts manually in a page, but that's generated in a template, AFTER the default query returned something else (page/post, etc) How do you query multiple posts in a public query, ...
71
votes
3answers
38k views

When to use WP_query(), query_posts() and pre_get_posts

I read @nacin's You don't know Query yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using query_posts() for all my querying needs. Now I'm a little bit ...
3
votes
1answer
251 views

Sanitation needed for WP_Query or get_posts calls?

Just wanted to get a straight answer on this: when submitting query_vars to a call to get_posts or WP_Query, is sanitation needed or does WordPress already take care of that?
0
votes
4answers
309 views

Why always one post missing

In my custom query, every time I query for posts from a particular category using WP_Query() and the category has 10 posts for example, I seem to be missing a post. So querying for 10 posts only ...
0
votes
1answer
66 views

How do I query posts and have their related taxonomies returned in the results?

I have created a custom post type that contains television channel data. Each channel has its own post. I have also created a custom taxonomy of channel groups. What I want to do is query all the data ...
0
votes
1answer
1k views

Use of caller_ get_ posts

For what purpose following parameter is used caller_get_posts
4
votes
1answer
481 views

How-to exclude terms from the main query the most performant way?

This Q is a follow up to this answer on the Q: "How to exclude a specific term for the search?". 4 ways to filter out posts that have a specific term Type | Pro | ...