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

0
votes
1answer
73 views

Change content off every sixth element

I would like to create custom post query where i will list all my posts in the list. Then the tricky bit is to add different content to sixth element off that list. So something like this ...
0
votes
3answers
165 views

Weird problem on if statement

I'm facing a weird issue trying to do what I'm going to explain now. Context Plugins I'm using: Custom Post Type UI / Advanced Custom Fields Functionality: I have a custom post type called ...
0
votes
1answer
940 views

How to make WP_Query not to show irrelevant posts?

I'm using the following WP_Query arguments array: $args = array( 'post_type' => POST_TYPE, 'tax_query' => array( 'taxonomy' => ...
0
votes
1answer
2k views

Posts limit on homepage (genesis framework)

in home.php // NOT working query_posts('show_posts=3'); // NOT working add_action( 'pre_get_posts', 'set_posts_per_page' ); function set_posts_per_page( $query ) { $query->set( ...
0
votes
1answer
241 views

Sticky posts don't show up first in custom loop

I'm using the following query in my frontpage template: <?php $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $args=array( 'paged' => ...
1
vote
1answer
3k views

Filter query_posts by tag slug on “Tag Archive” page (when tag is 2 or more words)

I'm using the following to bring up a tag archive page: <?php query_posts( "tag=". '' . single_tag_title( '', false ) . '' ); ?> This works perfectly for all tags of one word only, but any ...
0
votes
2answers
949 views

query_posts pagination will always show identical content

Anyone here see why my pagination won't work? I can get "previous page" to show up, but when navigating to "page-2", the content will stay identical to the content on "page-1". <?php /* Template ...
0
votes
1answer
2k views

query_posts doesn't order by title

It seems like stupid bug, but how can i order by title? It anyways orders by date! I'm using: query_posts( array( 'post_type' => 'page', 'posts_per_page' => -1, 'orderby' ...
0
votes
1answer
1k views

How to Loop within a Loop (Display Children and then Grandchildren)

I am trying to develop a query for WordPress that will allow me to display a list of child pages with titles only, and then under each child page title, a list of grandchilden (children of the child) ...
0
votes
1answer
2k views

Multiple post type queries (with specific arguments for each)

So i know how to combine post types into 1 loop and out put the loop. Below is what i have: <?php $args = array( 'post_type' => array('post','movie','actor'), ...
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 ...
1
vote
2answers
223 views

Query last updated posts (posts updated in the last 24 hours)

I'm having some difficulty to find an example of how to create a loop with posts that had been updated in the last 24 hours. My idea is to have a page of posts or perhaps on the index.php a lists of ...
0
votes
1answer
633 views

orderby not working for query_posts using array of IDs

I have an array of IDs that i send to query_posts to get the posts (which works fine) but it seems to always put the attachment(562) last even though it is the newest. Also tried title and ASC vs DESC ...
0
votes
1answer
1k views

order posts by meta value on posts page

I've been reading alot about how to order posts by a meta_value, but I can't seem to get it to work for me. My meta_key is called date, and it is stored as yyyy-mm-dd. Here's where I've gotten to so ...
2
votes
1answer
1k views

Custom search filter causes menu and query_posts problems

I'm using a custom search filter (using my custom query var type), like so: function fteh_pre_get_posts( $query ){ if( isset( $query->query_vars['type'] ) ) $types = explode( ',', ...
0
votes
1answer
201 views

why is the current page title being output?

this is in my sidebar.php file, which is pulled in in the header.php file (is this bad practice?). anyways, the last item in the list is the current page title, despite my query_posts with an args of ...
0
votes
1answer
189 views

Question about querying posts

I have this code on a query I'm doing <?php query_posts('post_type=vendors'); ?> <?php while (have_posts()):the_post(); ?> <?php $featured = get_field('promote_to_homepage', $post ...
2
votes
2answers
3k views

List posts by category exclude current post

I'm trying to get a list of posts from one category, echo the title and the permalink of all posts on that category but exclude the permalink and the post name IF the current post is on that list. It ...
1
vote
1answer
261 views

Displaying terms based on loop posts?

I have a shortcode that shows a loop for a custom post type: while ( $loop->have_posts() ) : $loop->the_post(); // do something endwhile; Some of the posts are in categories ...
0
votes
1answer
56 views

Help in query for list links

How to make one query for display a list of links like this: Date 05/20/2012 Category - Link Category - Link Category - Link Category - Link Category - Link Date 05/19/2012 Category - Link Category ...
2
votes
4answers
2k views

Unable to display multiple post types in same query (WPML WP_Query)

I'm sure there's some very easy explaination for this, but I'm stuck. I am just trying to put a nice, simple recent posts element on the front-page of a site and for some reason when I try to use: ...
1
vote
3answers
2k views

query_posts and pagination, still stuck after much research

I need to paginate some custom posts...I can’t see why but I’m getting 404’s when going to the next page. Here’s my code: $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( ...
0
votes
2answers
350 views

How to only publish posts with image in it

I use a standard loop in my index.php and that shows all the posts beeing posted. What i'm looking for is a code that only shows the posts that have image(s) in it. With other words: i only want to ...
2
votes
2answers
211 views

How to get 4 Posts after the 5 most recent ones

Well, I think the question might be a bit confusing. But well, I want to get the recent 4 posts, ignoring the first five recent posts. So in short the sixth, seventh, eighth and ninth - most recent ...
1
vote
1answer
1k views

How to make multiple sections in home pulling posts category wise?

This question may look foolish to everyone or novice , but i am working on a theme . It will be basically a news publishing theme . Right now , In my home page all posts are showing one after ...
1
vote
1answer
1k views

Sorting Posts Via Custom Taxonomy Values Using Checkboxes?

I am working on a project that has a dropdown of custom taxonomy values called "Disciplines", there are only 4 of them in the dropdown. The way it has been designed is that you can select more than ...
2
votes
2answers
11k 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
1k views

How to write sql query to get the posts from a custom taxonomy term name

I hope someone will help me............. I have a Post Type ----> Dealers Taxonomy ----> State how to write a sql query in this format $catinfo1 = $wpdb->get_results("select t.*,(select ...
0
votes
2answers
159 views

Currently using a query_posts() in my theme - want to use a request filter in stead

I am currently using this code in my theme right before showing the content of the custom post type my_post_type: $title = $post->post_title; query_posts( array ( 'post_type' => 'page', ...
1
vote
1answer
206 views

Get latest 3 posts from multiple CPT in one query

I'm looking to create a site wide feed on my site and have multiple custom post types. I'd like to display say 3 posts from at least 3 different post types. I can get the latest 10 posts across each ...
0
votes
1answer
2k views

Query only Posts from Both of Two Category?

I have 3 categories, 1.OnGoing projects(cat id='5') 2.Completed Projects(cat id='6') 3.Upcoming Projects(cat id='7') and also i have another 2 categories:(Not a Sub Category) chennai (cat ...
0
votes
1answer
876 views

Retrieve or Query Pages by ID

I have a problem with my code, I want to display 3 specific pages on my homepage but my code is not working.. here's the code.. <?php $args = array( 'post_type' => ...
0
votes
1answer
456 views

Best practice for multiple queries on page

On my WordPress site I have three categories 'moviestar', 'interviews', and 'movies'. On a 'moviestar' category page that is entitled 'Angelina Jolie' (and with a custom variable starname='Angelina ...
1
vote
1answer
214 views

How to fetch all posts in a category that were published between two given dates?

I need to be able to get all posts in the blog that were published in between two dates. The get_posts() API call doesn't seem to provide a method for limiting the time period of the returned results ...
80
votes
4answers
54k 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 ...
2
votes
2answers
409 views

How to order results by date and meta key?

I'm using wp-postratings to rate posts which stores the rating as a custom meta value ratings_score. It gives you the option to use r_sortby to order the loop by highest rated but I want to give it a ...
0
votes
2answers
3k views

How to create custom query by keyword in post title?

I need some help regarding Custom Query by keyword. I send a keyword to my page where I would like to list those posts which post_title contains the keyword I sent. Here comes my query as follows: ...
0
votes
1answer
406 views

Query specific posts from parent by slug rather ID

I'm developing a theme in a local machine and migrating it to a production server. To keep things in sync, i'm trying to avoid any queries of specific ID's On the homepage, i'm trying to query the ...
0
votes
1answer
1k views

How to limit the number of posts on the home page?

I am working on my first WP site and am having some difficulty. In my theme's index.php page, I see the following code: <?php query_posts(array( 'category__not_in' => array($headline), ...
1
vote
2answers
1k views

Using Query Posts With Multiple Post Types And A Taxonomy

I am developing a site that has two different custom post types; one of them is called Articles and one is called Sketchpad. Sketchpad is user submitted content that is assigned a custom taxonomy term ...
0
votes
1answer
998 views

Single-page wordpress theme navigation

I'm trying to build single-page theme. I want user to navigate thru menu with anchors (for example <a href="#About">About</a>). I've extended Walker for wp_list_pages so it outputs anchors ...
0
votes
2answers
3k views

How to order posts by modified date without using 'query_posts'?

I have an example basic wordpress theme template here for you. First, please take a quick look at it to get an idea. <?php get_header(); ?> <div id="primary"> <div ...
1
vote
1answer
480 views

Possible to display posts containing a short code ?

i have some posts with a certain shortcode in them. unfortunately these posts are in different categories and contain different tags so i am not able to query them. is it possible that i run a query ...
0
votes
2answers
3k views

get query's query string

By the time index.php runs, it seems as though there is already a query populated. How can I find out what that query's query string is? eg. new WP_Query([query string is here])
0
votes
1answer
60 views

How to check a list or feed of all posts under a category and tag?

Consider this question from the point-of-view of a visitor to a WordPress blog, and not as a WordPress blog admin who can edit those numerous PHP files. How can I see a list of all the posts under a ...
0
votes
2answers
321 views

Modify loop but keep the original query, what am I doing wrong?

I have a custom post type where I have a taxonomy cities and a term berlin. Archive can be seen at example.com/cities/berlin and it's rendered normally from the archive.php template. Now, I want to ...
3
votes
2answers
5k views

How to query for most viewed posts and show top 5

Here is how I am getting the views for one post: function getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); ...
1
vote
1answer
37 views

I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?

My website is a multi author blog. I would like to give special promotion for the first 100 published posts in my blog? What is the proper way to implement it? I mean should i add some meta value ...
0
votes
2answers
490 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'); ...
4
votes
1answer
2k views

Hide other users' posts in admin panel

I intended to run a multi-author site, I don't want the posts from other authors to be shown in /wp-admin/edit.php page. I managed solve this problem by the codes from this thread. The code is like ...