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
584 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 ...
0
votes
1answer
23 views

query_posts() doesn't seem to be called in my page

I've a problem with my query_posts() call. Here is my code: $results = $wpdb->get_results("SELECT post_id FROM " . $wpdb->postmeta . " WHERE meta_key = 'mashsb_shares' ORDER BY CAST(meta_value ...
0
votes
1answer
20 views

Div Missing In Custom Loop Query

I'm using a customized php code for my wordpress loop. The code is designed the break the post up to be styled differently via html & css. The code is also designed so that I can add div blocks in ...
0
votes
1answer
19 views

Add class to first post in custom loop using post_class filter

I am trying to add a class to the first post in a custom WP_Query. I can add a class to the first post of the standard WordPress loop using; add_filter( 'post_class', 'featured_classes' ); function ...
0
votes
1answer
23 views

Modify query to exclude certain ids and certain parents and its corresponding children

I'm trying to modify an admin query where I need to exclude a few pages based on two conditions: Exclude based on certain titles Exclude based on certain pages, including its children pages To ...
1
vote
2answers
573 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
429 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
1answer
590 views

Alter post order on taxonomy template

I have a taxonomy template that is returning the correct posts (actually a custom post type) but I want to alter the order in which the posts are displayed. However, nothing I've tried will change the ...
2
votes
2answers
589 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 'et_cycle';...
0
votes
1answer
414 views

How can I change the publish date based on a custom field?

How can I change the publish date based on a custom field? Author uses a date picker to choose the date for journal entry. The date is used to make a list of all the users journal entries. I can ...
0
votes
1answer
11 views

Filter posts by current date ( WP Post Carousel )

So i managed to filter the posts with this snippet : <?php echo " works"; $current_day = date('j'); $current_month = date('M'); query_posts('day='.$current_day.'&month='.$current_month); ...
0
votes
1answer
37 views

Filtering out child category posts from parent category archive not working

In this example cat 5 is the parent category, and 42 is a sub-category. I the main category 5 archive I don't want any posts from sub-category 42 displaying. Why isn't this working? function ...
0
votes
2answers
3k views

How to order posts by descending comment count on taxonomy page?

This lists the posts in my custom taxonomy template page: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> How can I order those posts by comment count?
0
votes
2answers
505 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 ...
6
votes
2answers
22k views

How to get posts published between a date and today?

Is it a way to get posts published between a date and today with query_posts() ? Example : All posts published since 2012-04-01 Thanks EDIT : How to add the filter date on this Query Posts ? ...
0
votes
1answer
16 views

Main site single-property.php design, as homepage of a multisite

I've been researching how to do this for some time now, and I'm coming up short. I have my main blog, example.com, which we've created a custom post type of Property. I'm needing the exact layout and ...
1
vote
4answers
16k views

How to set posts per page using WP_Query()

I'm trying to set the number of posts_per_page dynamically using my own variable. This code works fine: query_posts( $query_string . "&posts_per_page=" . $myvar ) // then display the loop using ...
-1
votes
0answers
24 views

What is the one-query (or the fastest) way to get posts and their terms (more taxonomies)?

Now this might seem like a similar question One query to get posts and their taxonomy terms but it is just similar and does not have proper answer. Goal: I need to get limited number of posts and ...
0
votes
1answer
4k views

How to display posts from a single category within a custom taxonomy

I am trying to list only the posts from a single category of my custom taxonomy. I have created a custom post type called "Inventory" and a custom taxonomy called "Inventory Category". I then ...
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
24 views

Ajax custom taxonomy and query_posts

I'm trying to add ajax load more function on my custom taxonomy template. I'm stuck, It works for me on category templates and stuff, but not on taxonomy template (archive). So, here's my loop ...
-1
votes
1answer
614 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'); } ...
0
votes
3answers
208 views

query_posts result differs from wp_query request result

I have a multisite Wordpress setup (3.5.1, I cannot risk updating) on which I am querying some posts after having switched to the correct blog. I have a query_posts function with the following ...
0
votes
1answer
29 views

How to get posts from a current post's month?

I want to display the titles of the post of the same month as the blog post. I tried this .. <?php $year = the_date('Y')?> <?php $month = the_date('M')?> <?php $theids = $wpdb-...
0
votes
0answers
13 views

Filtering search results for nested loops

So I have a list of companies that have counties and cities. I need to be able to do something like /findmanagers/miami-dade/ and then build a query that fetches all the companies we have listed ...
2
votes
1answer
31 views

Taxonomy.php issue with search and filters [Solved]

I'm trying to create a custom taxonomy.php page where my users can refine search into that context. I've tried to create a kind of loop like: <?php if(!empty($_GET['ending'])) ...
1
vote
1answer
39 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
21 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
17 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
86 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
48 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 ...
4
votes
2answers
59 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
72 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 ...
8
votes
2answers
144 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
70 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 ...
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
591 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
4k 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
15 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
58 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
1answer
49 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 ...
0
votes
0answers
22 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
51 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
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
60 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 ...
1
vote
0answers
66 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 id="...
0
votes
1answer
30 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 class="...
0
votes
0answers
39 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 ...