Set up The Loop with query parameters. This will override the current WordPress Loop and shouldn’t be used more than once. This must not be used within the WordPress Loop.

learn more… | top users | synonyms

1
vote
1answer
10 views

How to build a WP_Query using mulitple tags and using AND or OR operator between them

I'd like to craft a query to return posts based on the conditional presence of certain tags. The pseudo query is: return posts with "((tagA OR tagB) AND (tagX OR tagY))". But I'm having issues ...
0
votes
1answer
19 views

How to sort posts according to meta value?

How can I sort all the posts according to their meta value? I am using the below code: $args = array( 'meta_query' => array( array( 'key' => 'wpcf-stream', ...
0
votes
1answer
10 views

Sort Events by Venue Title - Sort Post set by related post ids

In wordpress, I am using The Events Calendar Plugin to host events. This includes two post types: events and venues. On an index page, I would like to list ALL events, but ordered by their ...
0
votes
1answer
31 views

How to provide meta_key array to wp_query?

I'm trying to build a wp_query, so far I've managed to get desired result using following query. $args = array( 'meta_query' => array( 'relation' => 'OR', array( //check if ...
2
votes
2answers
35 views

_wp_page_template to dynamically use template

I'm wondering if it is at all possible to set display a page template chosen by the user within the context of a query_posts using get_template_part. In other words, I have set up a page template to ...
3
votes
2answers
51 views

Are there any scenarios where the query_posts may be used?

I feel there is a red button saying "Do not press" below query_posts(). For some time I am trying to demystify this phenomena with very low success to be honest. For example, probable the main ...
3
votes
2answers
64 views

Is `query_posts` really slower than secondary query?

I know the main query is fast, since it gets data after parsing the URL and after WP_Query has been instantiated. We are in OO PHP. But is query_posts really slower than some secondary query that ...
7
votes
2answers
116 views

Why query_posts() isn't marked as deprecated?

There are two query_posts() functions technically speaking. One query_posts() is actually WP_Query::query_posts() and the other is in global space. Asking from sanity: If global query_posts() is ...
0
votes
0answers
11 views

How to query post from sub-categories on category archive and display posts?

On a custom taxonomy archive from the taxonomy called 'books' (taxonomy-books.php) I want to list all subcategories that are assigned to the parent category. And then for each subcategory I want to ...
1
vote
1answer
556 views

Too many posts cause slow load when paginating

I have about 10k posts and I made a page that lists all posts but it is paginated every 54posts. It gives 131 queries in 6.730 seconds which is pretty slow to load. Is there a way to make it load ...
-1
votes
0answers
15 views

Nested list output

I'm listing my custom post type posts ordered by their taxonomy like this: Taxonomy1 --post1 --post2 --and so on Taxonomy2 --post3 --post4 --and so on I use this code <?php $design_group_terms ...
4
votes
4answers
1k views

How do I create a random post that will last for a day

How do I create a random post but it shouldnt be change when the page is refreshed I want a random post that will last for a day and after 24 hours or a day, it will change randomly the post , ...
4
votes
1answer
579 views

Query posts: how to exclude results if post is in multiple categories

Say I have 3 categories: A, B, C, and another category D that posts in A,B,C can also be assigned to. D is to denote the featured post for the category, and theoretically only one post for each (A, ...
-1
votes
1answer
21 views

Filter Query Post by Custom Fields(by date)

I want to filter query_post using the 2 meta keys start_date and end_date, i want to get my posts to divide it by upcoming events and past events. start_date and end_date is stored in the timestamp ...
0
votes
2answers
3k views

Display one latest post from multiple categories

This should be very easy, however for some reason I can't find a working snippet anywhere on the web.. I basically need to display one latest post from 6 categories (can be changed to 7,8, etc etc) ...
0
votes
0answers
14 views

Publish four random posts each day

I am currently using the following code to publish four posts in my home page. query_posts('cat=14&showposts=4&offset=1'); if (have_posts()) : while (have_posts()) : ...
0
votes
0answers
21 views

Search result by taxonomy name

Currently my search filters by title and I'm trying to filtered by taxonomy tags. How do you I do that. Here is my code: $query = " SELECT * FROM $wpdb->posts WHERE $wpdb->posts.post_status = ...
1
vote
2answers
575 views

Include a specific post to the query_posts and remove it if it is already in the returned list

Bare with me. Firstly, here is my whole script for my featured slider articles: <div id="featured" class="<?php if ( $responsive ) echo 'flexslider' . $featured_auto_class; else echo ...
0
votes
1answer
534 views

query_posts with offset breaks pagination

I have this code in my front-page.php template: <?php if (get_query_var('paged')) { $paged = get_query_var('paged'); } elseif (get_query_var('page')) { $paged = get_query_var('page'); } ...
1
vote
1answer
31 views

pass query string on url to filter media

I have an author page which shows all uploaded media by that author. Each media can have tag1, tag2 or tag3. I would like to add an option where I can show on that same page only tag1 media without ...
1
vote
2answers
545 views

How to optimize 'select found_rows()' query? Several 'high load average' alerts daily

I have 5,000 regular posts, 6,000 posts in one post type and 2,000 posts in another post type. Needless to say, that has made the wp_posts table quite large. Not to mention, I have custom taxonomies ...
0
votes
1answer
423 views

get_next_posts_link() stops displaying at page 4

Please start by taking a look at this quick video: http://www.screenr.com/8vSH The problem: get_next_posts_link() disappears on page 4. That is, the "go to older posts" link disappears once I am in ...
0
votes
0answers
21 views

Query returning 1 post per page but saying it has 71 pages with almost 1500 results in total

Something is definitely not right here and I honestly cannot understand what it it. After I put this code on one of my custom made plugins, although it makes the search correctly (the result ...
1
vote
1answer
33 views

Query with custom taxonomy not working

I have custom post type 'mix'. And custom taxonomy 'meal'. And categories in custom taxonomy (one of that is with slug: breakfast) I have problems with making query. My code is : $args ...
0
votes
0answers
10 views

Category and post_lists

I´m trying to make a template for a wordpress site where i need to fetch posts form two different categories - two times. (ie.two loops) But seems like the category sort is just working for the ...
-1
votes
0answers
13 views

Issue setting showposts using query_posts()

I have the following code block which works correctly, pagination also works correctly. However If I un-comment the query_posts call, my pagination breaks. Can anyone suggest a solution here? ...
1
vote
1answer
2k views

Querying custom posts and regular posts

I want to populate the "Greenway News" box on this page with the three latest headlines from the site's Press section AND blog. The blog is a regular WP blog and I am currently using this code to get ...
0
votes
1answer
39 views

posts_per_page override by default settings

I'm running some template files outside of the actual theme and I am displaying some posts on this templates. Everything worked absolutely fine but some days ago (maybe the update to 4.5) the default ...
0
votes
2answers
468 views

Custom search SQL Query to add custom field in result

I have to write my own MySQL query since I haven't found a good way to do it within wordpress functionality. I want the search query to search trough post_title / post_content & meta_key ...
2
votes
2answers
4k views

get_query_var('paged') always returns empty

Putting this up after having hit a brick wall for possible solutions. Have a site with quite a few custom post types and associated custom taxonomies. To help make things easy, I'm using a unified ...
0
votes
0answers
30 views

Frontend Post with JQuery AJAX to Php Issue

My problem is the following. I'm trying to make users publish custom post_type by frontend through a form like this: <form id="msform" enctype="multipart/form-data"> <fieldset ...
0
votes
1answer
22 views

Trying to show Wordpress category query result as background image

The code is working fine so far, but I want to show the post thumbnail as a background image inside the li tag. Been trying many variations, but can't work it out? Here's the code: <div ...
0
votes
0answers
38 views

Omitting the latest entry with custom type and taxonomy term from the loop

My agency has inherited a client with a customized theme provided to them from a separate agency, which farmed the work to another agency off-shore. The documentation for this theme is non-existent ...
-2
votes
1answer
49 views

How to remove post duplicate when using query_posts('offset=1')

I used query_posts('offset=3') in index.php, while there exist a problem in pagination. In all page it show the same content of first page. How to solve this problem?
0
votes
0answers
12 views

Configure number of posts to show on Wordpress page using Redux Framework

I am using Redux Framework for theme options on a theme I am working on. I want users to be able to set the number of posts to show in a certain section. Right now it's hard coded to 3. But I added ...
0
votes
2answers
62 views

Fetching $_POST from Page Template into functions.php

I'm having an issue with the order WordPress is loading page templates and functions.php. I have front-page.php which has $_POST['sort-by'] allowing users to sort posts using a drop-down menu. It's ...
1
vote
1answer
53 views

Query all posts if multiple meta key don't exist

I'm trying to get all posts that don't have a meta ket that starts with aa_. I can do it this way $args = array( 'posts_per_page' => -1, 'category__in' => 23, 'meta_query' => array( ...
0
votes
1answer
20 views

order posts by `meta_key`, Does not display posts that does not have `meta_key`

I'm using this query orderby meta_key for show posts. if one of the posts does not have vip_row meta, So not shown; Is it possible that if one of the posts does not have vip_row meta to be ...
8
votes
1answer
13k views

Get posts from sites in Multisite?

I'm trying to pull multiple sites posts. For example, I can pull out a single site posts by a category and total posts 10. But I'm trying to pull out both posts from two separate Multisite blogs 1 ...
5
votes
3answers
26k views

How to show all posts of the category in wordpress?

I have create a category by using Custom Post Type plugin, and now only the 5 most recent posts of the category are showing. What I want is to show all posts for the category. For examle, suppose I ...
1
vote
3answers
43 views

Unable To Get Published posts using query_posts

I'm not sure why this is not working as its a very simple query. It works when i pull all posts including pending, but not when i want to get posts that are only published. I have a function to get ...
-1
votes
1answer
87 views

Modify Blog Module layout in Child theme

I need to adjust how the featured image is displayed in their blog module. I need to change the display of the Featured Image from an IMG tag to a Background Image. So I can modify the frame (DIV) of ...
5
votes
5answers
43k views

how to query posts by category and tag?

I am trying to show a list of posts that are related to category X and tag Y. I've tried the following code: $args = array( 'posts_per_page' => 4, 'tag_id' => $tag_id, 'cat' => ...
1
vote
1answer
2k views

Ensuring sticky posts are retrieved first (without using two queries)?

I need to maintain pagination for use with infinite scroll. Is there no way to tell query_posts to retrieve sticky posts first? It seems to be default behaviour on a standard wordpress blog on the ...
4
votes
1answer
1k views

Some doubts about how the main query and the custom query works in this custom theme?

I am pretty new in WordPress theme development and I'm not so into PHP (I came from Java and C#) and have the following situation in this custom theme As you can see in the homepage I first show a ...
1
vote
4answers
101 views

2 loops on page - one with orderby rand second orderby date

What I'm trying to achive, is to set 2 loops on one page. First one takes 11 latest posts and sort them in rand order. Second show the rest of posts ordered by date. FIRST LOOP $args = ...
0
votes
1answer
20 views

How to set class to “current-page” on the currently viewed single post within a CPT

I have a custom post type, "case". I'm currently editing the single-case.php file and in my sidebar I have the following piece of code: <?php $case_query = array ( 'post_type' => 'case', ...
1
vote
2answers
432 views

using post__in allow duplicate post id

I have an array of ids in a specific order. I use post__in in my query to get posts from this array. I have some duplicate post IDs that I need to show twice in the page but the query seems to ignore ...
4
votes
2answers
3k views

How To Modify The Loop in archives.php To Have 11 Posts Per Page and CSS Styling

I edited my loop in archives.php in order to work with pagination and with the Category Post List Widget. I basically pieced it all together from random code and ideas and am now so far from the ...
0
votes
1answer
36 views

Create a hierarchical loop at predefined markup requirements

I try to achive this in wordpress based on my theme: fullpage.js demo So I have a predefined markup for vertical sections (parents) and one for horizontal slides (children). Parents only contain ...