Tagged Questions

"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

2
votes
3answers
107 views

PHP memory friendly alternative to get_posts()

I was running into memory issues with this: get_posts( array( 'posts_per_page' => '-1', 'post_type' => array( 'product', 'product_variation' ) ) (there are thousands of results) just trying to ...
6
votes
2answers
244 views

Is it possible to query all posts that don't have an attachment?

I want to get a list of all posts that don't have an attachment and delete them. This question takes about getting all posts that have an attachment, but I want the reverse of it. The brute force ...
0
votes
0answers
23 views

Returning error with WP Insert without getting an error in error log

I'm checking if a key exists in my database using $wp_db->insert() and am executing code based on the result. I know that if a row already exists it will return false and I want to use that to execute ...
1
vote
2answers
65 views

WP_Query posts_per_page Only Bringing Back one post

I'm trying to modify the Genesis Tab plugin to show more than one post per tab. I've tried in vain for the past hour, but my little PHP knowledge just isn't cutting it unfortunately. Here is the ...
4
votes
1answer
69 views

How to place a loop within another loop?

I have two loops setup using WP_Query: $latest and $popular that I'm working to setup in this example layout: Latest                        ...
0
votes
1answer
94 views

How to show subcategories using loop?

i am using wp_list_categories('child_of=54&title_li=') method to display all the subcategories, but it is showing only one, how can i use it with loop to show all the subcategories properly.
0
votes
0answers
26 views

How to sort post by custom table value

How can I sort my post by the maximum vote in custom table I have table like this:( user_votes) here post id 315 have votted two times so I just want to sort my posts by maximum vote. I am only ...
3
votes
1answer
48 views

Query Custom Meta Value with Increment

I have a Query searching for a meta value I have added to my posts (meta-select). I have it feeding out in a loop with 4 results. Let's say I want this loop to start with the meta value "2" and work ...
0
votes
1answer
88 views

wp-query, pull children of parent page

So here's what I'm trying to do: I'm trying to develop a theme that shows any sub-pages on the parent page. I've gotten this running successfully with a WP_query and a simple loop: <!--show sub ...
0
votes
1answer
45 views

WP_Query Meta_key is text value and need to sort as numeric not working

I have the following code below in my ~WP_Query`. $args[ 'meta_key'] = 'price'; $args['orderby'] = 'meta_value meta_value_num'; $args['order'] = 'ASC'; The custom field in question has historic ...
0
votes
0answers
51 views

Sort CPT by first letter of a meta field in a specific range

'I'm working on a way to display member profiles (Custom post type) sorted by the first letter of their last name in a given range. For example all members with a last name starting with 'A' up to ...
0
votes
1answer
40 views

Meta query for comparing two dates

I want to list all users who registered in between the $start_date and $end_date.I have written a metaquery,but it returns empty.Please help. $start_date = 2014-08-16 09:28:17 $end_date ...
0
votes
1answer
51 views

foreach,having wp_query inside, breaks after showing one result

I am trying to make category tabs that show posts from selected category tab. I have tried it my way but m getting only one post for each category, whereas it should return all post in that category. ...
0
votes
1answer
68 views

Values inside a custom field to determine which category posts to display

I am facing a little problem whilst trying to display posts, from certain categories, on the front end. I've created a custom field whose key is 'related_categories' and I've different categories with ...
0
votes
2answers
31 views

How to make “Blog pages show at most” setting not affect custom queries

I want my blog page to display 5 posts at most. But I have many custom queries (wp_query) on my site, some of them embedded together: how to make Settings > Reading > Blog pages show at most ...
0
votes
1answer
63 views

How do I get my custom query to work with search results after the first page?

I am using a custom query in order to ajax load/append additional posts instead of paginating them out like WP defaults. However, when I click the button I've made to load more posts, it loads all ...
0
votes
0answers
49 views

70.000 custom posts on my site

My site have more than 70.000 custom posts. Admin panel not show all posts. how to fix it ? Month filter: more than 4.000 posts. it's normal.
0
votes
0answers
28 views

404 page is not querying my custom post

I have a 404 template page which is, obviously, designed for Not Found Pages. Within the code, I have the get_header(); where I place the global code for the site. There is a div that contains a style ...
2
votes
1answer
72 views

Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy

I have registered a custom post type "Animals" and also two custom taxonomies ("Vertebrate" and "Type") assigned to it, which have their own specific terms, for "Vertebrate" it will be "Mammals" and ...
2
votes
1answer
156 views

WP Cron and wp_insert_post

I'm trying to insert posts using a cron job, but I keep running into errors where WP is missing functions (is_user_logged_in, wp_get_current_user). Is there a proper way to run wp_insert_post using a ...
0
votes
1answer
67 views

Can't display shortcode in WP_Query loop

I want to display all posts from my CPT brand. My WP_Query loop works well but the shortcode I want to use within it doesn't work. This shortcode comes with some plugin called Download Attachments, ...
0
votes
0answers
47 views

get_terms vs wp_query for pages - results inconsistent

I have a situation where a custom post type, with a related custom taxonomy. There are somewhere in the realm of 100 of these posts. The taxonomy associated to it has about 20 terms associated with ...
0
votes
0answers
44 views

Filter WP_Query output before it is accessed (pre_get_posts)?

I have read Using pre_get_posts with WP_Query and I'm not sure where to go with it. I have a recent posts plugin which adds variables to WP_Query - one of which can be 'offset' posts. The problem is ...
0
votes
1answer
94 views

Custom post type archive organized by category

I'm trying to display a custom post type archive page which displays all the articles of a a custom post type in columns. The columns organize them in their assigned category. On the main page, I do ...
6
votes
1answer
168 views

Inject post (from specific category) between posts in Loop

I would like to add a post (from specific category) between posts in the WordPress Loop (such as 'Sponsors'). Example: P P P S P P S P P S P P How can I achieve this? I am a beginner with coding, so ...
1
vote
1answer
32 views

How to create a custom shortcode based on the layout?

Hi I am developing a custom post type plugins. Which has shortcode support. Already i have created a shortcode which is going to use for default layout design. Again i have to create a onemore ...
0
votes
0answers
90 views

Display related posts with same category or same tag return blank

I'm trying to display 4 related posted in the same category or have the same tag with the current post on the single post page. The result is just blank. <?php $rCateogry = ...
0
votes
1answer
136 views

Pagination on category page with custom post types

Wordpress is not new for me but I am really stuck on this piece of code that I can not get to work properly. I register a custom post type News and let the custom post type use the Wordpress ...
0
votes
1answer
55 views

The sorting of posts by a meta_query with two keys fails while separated as single queries it works

I have a list of courses I try to sort. For sorting purpose I want to use two advanced custom fields. First a select field class_day containing the days: 1 : Mon 2 : Tue 3 : Wed 4 : Thu 5 : Fri 6 : ...
0
votes
1answer
55 views

foreach loop inside the loop creating duplicates in output

I have a foreach loop inside the loop that is getting info from a separate table. The table has a column that has an id that reflects the id of the post type so it should always be unique. When I ...
1
vote
1answer
27 views

Filter Posts from the Main Query

I want to conditionally merge a custom post type with my posts post type, based on a custom field. If the field's value is 1, then I want I need those custom posts to appear in the same loop as posts ...
0
votes
0answers
16 views

Displaying four post types sharing one taxonomy

I was hoping somebody could help me. I've created a custom taxonomy 'members' that is shared by four post types - posts, pages, resources, and news. I've then added five terms using this 'members' ...
3
votes
1answer
135 views

WP_query taxonomy + get all posts with two terms from same taxonomy

This is a follow up question to Add_query_arg + two times the same argument? I want to get the post count from all posts tagged with 2 different tags from same taxonomy $args2 = array( ...
0
votes
0answers
39 views

How to show the posts list into a static page? Problems to use the loop into a static page

I have the following problem: I have to create a posts archive into a static page. So I have created this page template containing the loop to interate on my posts: <?php /** * Template Name: ...
0
votes
0answers
699 views

How to load more custom type posts through AJAX & LOAD MORE POSTS button

Guys I am a little stuck here. Unable to load posts from a custom post type through AJAX. Normally I have had been using this script http://goo.gl/lwfM5 It seems so that $wp_query is not getting the ...
0
votes
0answers
47 views

Memory size exhausted when extending WP_Query

I tried to create a class that extends WP_Query, but I got this error: Allowed memory size of 1073741824 bytes exhausted I've increased the memory size in wp-config.php but that doesn't affect. ...
4
votes
2answers
250 views

count posts from custom taxonomy terms by year

I want to build statistics-like tables with the count of posts in given custom taxonomy terms and display them by year along with the total post count from that year. For example: 2014 ...
0
votes
0answers
37 views

Horizontally paginate through sets of blog posts?

I have my posts set up like this: I would like users to scroll through the posts using the left and right arrows. So when users click on the right arrow, for example, the next six posts would slide ...
0
votes
0answers
38 views

Run a Wordpress function inside a wp_query loop result [duplicate]

I have a search results page that displays multiple results in a multi column layout. I am trying to run a function via a button/link that will allow users to add that post to a "favorites list". The ...
0
votes
1answer
40 views

Sorting posts by Multiple custom fields in defined order

I'm currently sorting some posts out by custom fields 'role' and 'surname', using the following: function customorder($orderby) { return 'mt1.meta_value DESC, mt2.meta_value ASC'; } $args = ...
2
votes
1answer
28 views

How to get_queried_object on multiple objects?

My Setup I have a custom post type "zap_apartments" with 2 custom taxonomies "zap_audience" & "zap_cities". I wrote some RewriteRules to access all "zap_apartments" for a "zap_audience" + ...
0
votes
2answers
96 views

How to get all unique categories for posts in loop?

I'm looking to get a plain list of the unique categories in a custom loop (only categories for the posts in the loop). I've been fumbling with some code for a bit and here's what I've got: <?php ...
0
votes
0answers
18 views

Multiple loop to display specific post at start of a list

I'm currently querying the following posts: <?php $args=(array( 'post_type'=>array( 'premium_content', 'post'), 'posts_per_page' => 3, 'orderby' => 'PREMIUM_CONTENT_FIRST!', ...
0
votes
0answers
26 views

Carrying values from page to page using custom query

Im having trouble paging a custom query and I hope one of you can spot my error and point it out. I've been looking at it for long time and tried many solutions but none seem to work. The code which ...
0
votes
1answer
44 views

Query Event Posts by Date

I am trying to query custom post type (Event) by the current date and the event's start and end date. I would like three options: current, upcoming and past. This is the code I am using, but it is not ...
0
votes
0answers
24 views

Order by post_type within loop

Envision the following: <?php $args=(array( 'post_type'=>array( 'premium_content', 'post'), 'posts_per_page' => 3, 'orderby' => 'PREMIUM_CONTENT_FIRST!', 'meta_query' => array( ...
0
votes
1answer
72 views

I need to run a AJAX Fuction from within a WP_Query but only works on first item

I have a page where users filter results from the Ultimate WP Query Search Filter plugin. The results are shown in a DIV via an AJAX call. This is working 100%. However I have another AJAX function ...
0
votes
1answer
58 views

Remove echo from shortcode

I've just started playing with shortcodes and due to my lack of php knowledge I am unable to figure out how to make this shortcode work without using php echo. Can anyone help me revise my code? // ...
0
votes
0answers
16 views

Get first page of given category

I am not a WordPress expert, so I'm seeking your help. I need parent ID of post category (closest parent, not "grand-parent"), then use it to get the first post of that category. I have folllowing ...
0
votes
0answers
36 views

global wp_query returning wrong post vars

I am currently filtering the_posts to recreate wordPress' "sticky post" function for custom post types. I also have to make sure that the sticky post is attached to a certain taxonomy term that ...