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
336 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
17 views

List all posts in taxonomy term

I have a custom post type called anime and a taxonomy called series. If I view any post and that post belongs term Banana it should list all the posts in term Banana in a dropdown list. Here's the ...
0
votes
0answers
9 views

Auto create child post from custom field?

I have a custom post type that has 3 custom fields. If I create a post with data filled in those 3 custom fields I want it to auto create child posts for each custom field & using the data from ...
0
votes
1answer
375 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 ...
2
votes
2answers
2k views

Sort Posts by Multiple Meta Values

1) Custom Post Type named "Buying_Locations" 2) Each Post has three meta values of: State, City, Store Name QUESTION: How can you show a list of these posts sorted alphabetically by State, then ...
0
votes
2answers
53 views

query_posts different amount of posts per page

I have a posts_per_page query to paginate multiple post types, which works great! Now though, as it paginates it to show (in this case) 100 posts per page, I'm wondering if you can show 100 on page ...
1
vote
1answer
465 views

How do I create my own nested meta_query using posts_where / posts_join?

Some of my posts (not all) have a price as a meta key/value. Today I use the pre_get_posts action so that my users can search for prices that are between a certain value. This is the code that I'm ...
209
votes
6answers
70k views

When should you use WP_Query vs query_posts() vs get_posts()?

It seems like half the tutorials in the Codex and around the blogosphere use query_posts() and half use WP_Query. What's the deal?
0
votes
1answer
281 views

Search a title word through query_posts (not the exact match)

We're working on a database with personal data from different sportsmen such as name, height, weight, etc. We've managed to build a detailed filter through query_posts. Every filter field is working ...
0
votes
1answer
331 views

Transfer taxonomy to custom field

I have a blog with movie critics and I'm using many taxonomies to add some informations about the movies, like director, actors or it's year. Using taxonomies is really useful to display all movies ...
1
vote
1answer
1k 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
20 views

Wrong post title displayed from loop

I'm building my own theme. I have a page set for my blog (with a template that I made) which I'd like to just display a few of my posts. It uses the following loop: <?php ...
0
votes
0answers
25 views

Advanced Custom Fields shows all posts

My ACF plugin shall only show posts with my organisation type = socialbusiness. Somehow it doesn't even care about my meta_query, it also doesn't care about the categories I selected (it shows "blog" ...
0
votes
1answer
555 views

Filter posts by multiple checkbox categories

I would like to set up a widget to filter my post by categories. Let's say, I do have two different categories, "Countries" and "length of stay" with sub categories. Here is an example of what I have: ...
1
vote
3answers
2k views

Loading post content in FancyBox

I got a tricky question. I have created a custom post type whose posts I would like to display in a scrolling carousel. The carousel will only display the title, the excerpt and a "read more" button. ...
0
votes
1answer
19 views

2 queries with counters

I have 2 loops on a page both containing a counter to implement slightly different code every 6 posts. For some reason though the second loop is implementing the different code sometimes after 4 items ...
1
vote
1answer
302 views

Getting movie and serial on actor page

I'm building a cinema site, I came with a problem, let me explain: Movies- are stored in Post's Actors- are stored in Post Type - persoane ( taxonomy= lista) Serials - are stored in Post Type - ...
0
votes
2answers
451 views

Getting custom post type info using get_adjacent_post

This is an example of how I'm grabbing images from my custom post type now, using query_posts(); // query_posts stuff made up here. $my_array = get_custom_field('image:to_array', 'to_image_array'); ...
0
votes
1answer
321 views

Getting images from media library and get_the_date() not working

I've got a function to display all images in the media library on a page. I would like to display the date of each image, but using get_the_date() only returns today's date. Here is the code I'm ...
0
votes
1answer
28 views

Query all post types but limit to parents

I'm building a site with several post types and am using a single index.php to query the archive for each one in turn. One of these post types is hierarchical and I'd like to just query the parent. I ...
1
vote
1answer
494 views

Checking for two categories in query_posts

How can I check two category_name values in the following query_post? <?php query_posts('category_name=recent-work&posts_per_page=1'); if (have_posts()) : while (have_posts()) : ...
3
votes
1answer
398 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, ...
0
votes
1answer
27 views

post_parent array doesn't work

I have a problem. I created a shortcode to show a galerie. I used query_posts to fetch all posts of a parent post and get the data from there: function galerie_baureihe() { $parent_id = ...
-1
votes
0answers
29 views

How to select posts with categories by SQL select

Im trying to show some post from a specific category ( from a custom post type) by sql select, I manage to show all post by: <?php $post_date = get_the_date('Y-m-d'); $start_date = date("Y-m-01", ...
0
votes
2answers
1k views

Pagination on category.php and tag.php not working

i'm using a query-loop on my template pages like this: <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query(); ...
1
vote
2answers
67 views

List posts in alphabetical order

What I'm trying to achieve is to set the list shown in alphabetical order. Any thoughts on how i can successfully achieve this? I have pasted the snippet below for reference. <ul ...
3
votes
1answer
94 views

Improve or optimize a very slow query

I have a fairly large database - 113,299 rows in wp_posts and 216,0649 rows in wp_postmeta. There is one custom query that I run after a post is added or edited, which appears in MySQL's slow-log ...
0
votes
2answers
3k views

Exclude current post ID from loop in sidepbar.php

Currently all the below bit of code is doing is showing 3 random posts from the same category that the current page resides in. So if the current page falls in the artists category, for example, show ...
3
votes
3answers
1k views

Display posts of the last 7 days

I'm trying to display the 5 best rated posts of the last week (7 days) on my website, however I can't seem to figure out how to display them. Here's what I've achieved so far but it doesn't seem to ...
0
votes
1answer
7 views

get “read more” with custom DB query like you would with WP Query

I am using a custom database query to fetch posts. In the post I have a break tag, which is displayed as <!--more--> in the database wp_posts table, but I can't get it to output like I would if ...
-1
votes
1answer
60 views

limit number of post for achive page

Im trying to limit the number of post for my archive page, in a specific category. I've manage to display post from just the category I desire, However, if i setup a loop to limit the number of ...
-1
votes
1answer
30 views

Create “archives by year and week” by category template

I'm trying to figure out a problem quite tuff; I explain myself; I have my pages ( which are in fact a category template). I take for example this website: http://www.irishpost.co.uk/ Where the ...
0
votes
0answers
32 views

Carousel with most viewed posts from last 7 days

I'm looking for a way to display the most viewed post from the last seven days into a carousel ( displaying the image thumbnail, and the title). I'm using a existing carousel, and trying to tweak it ...
1
vote
1answer
278 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
0answers
18 views

Sorting with custom field and 'comment_count' - orderby

How can I also add comment_count to my existing query? Below query works fine and sorts the archive with highest rating_avg only, I would like to sort my archive using rating_avg first and then the ...
2
votes
2answers
2k 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
1answer
14 views

Custom pagination generates title 404

I know it's a common problem, but I tried every solution appeared on this stackexchange. Every solution has failed (maybe because I'm still a newbie). I've this query on index.php page: if ( ...
0
votes
1answer
326 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 ...
1
vote
1answer
34 views

Order posts by condition

I need to get 15 posts. If there are any with a tag featured, I want them to be first. If there are none, I want the rest to be random posts. My idea was to sort posts based on a condition ...
0
votes
1answer
66 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
2answers
402 views

Related Posts: Notice: Undefined offset: 0

I get an undefined Offset message with this Query. Can anyone Help? $terms = get_the_terms( $post->ID , 'filters', 'string'); $term_ids = wp_list_pluck($terms,'term_id'); ...
0
votes
0answers
10 views

How do I make query use exact post title

I am creating a custom search query in wordpress and the post title isn't matching. I want it to say the posttitle and the firstname have to be exact matches, or nothing should come up under the ...
0
votes
0answers
15 views

Modified query_string has stopped working in WP4

The code blow was used to load a filtered taxonomy archive and worked fine up until the release of WordPress 4.0. Since upgrading to 4.0, it's not returning any results. Any ideas what might have ...
0
votes
2answers
7k views

How to display posts by current user/author in a custom page template?

I am a trying to create a dashboard like custom page template that list post of of the current logged in user. I've tried to find a solution on the net. but none were appropriate
0
votes
2answers
45 views

ascending order custom post type

I'm trying to sort a custom post type in ascending order (instead of the default descending). Registering the post type like so: function codex_custom_init() { register_post_type( 'calendar', ...
1
vote
1answer
7k views

How to get current post id of a custom post type in a loop using template singel-{custom type}.php?

I have a custom post type template where am looping through all post. what i am trying is when i go to my custom post page i want to get the current post id in the loop. So i tried to check if the ...
0
votes
2answers
47 views

Show single posts date, in a page of posts

In a page of posts, how do I show their date, instead of the page date? I have no php knowledge. Let's say I want to show the single posts date here, instead to the single posts title. <?php ...
2
votes
2answers
2k views

Get posts by meta data OR title

I have a working query that calls all my posts that have a certain meta value for one of two meta keys: $term = $_GET['term']; $args = array( 'post_type' => 'some_cpt_name', 'meta_query' ...
0
votes
2answers
102 views

Get post ids from WP_Query?

Is there a way I can retrieve an array of post ids queried from the following: $latest = new WP_Query( array ( 'orderby' => 'rand', 'posts_per_page' => 3 )); if ( ...
1
vote
1answer
27 views

Inserting custom data to the_post() during loop

I have some posts on my WordPress site, and let's say I want to add a random number for each post with $num as key and random() as value. Then I want to access them with something like: $post->num ...