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
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
694 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
433 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
203 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 ...
73
votes
3answers
47k 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
391 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
368 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
923 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
461 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
313 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
4k 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
452 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 ...
0
votes
1answer
1k views

Want Page Descendants when using query_posts post_parent or child_of

I'm trying to use query_posts to list all descendants of a page ID. Using post_parent only lists the first-level children. This Trac ticket seems to address it: ...
0
votes
1answer
108 views

grab neighboring content in a query

I'm grabbing a post based on a querystring parameter. How can I get the neighboring posts for a previous and next button? This will get tricky when you're on the first/last items. Here is how I'm ...
0
votes
2answers
575 views

Conditionals if tags exist?

I have the following code to display tagged articles with the same name as the page title, but I only want the to appear if the tag exists, otherwise it just says 'Related Articles' with no content. ...
3
votes
1answer
2k views

Filtering posts by post meta data

I want to filter posts in such a way that only posts, for which get_post_meta($post->ID, "project_cat", true) (it returns a post ID) is equal to my specified value, are shown. Any way to do this? I ...
3
votes
1answer
182 views

How should I intercept the main query and inject custom join / order by / group by criteria

I have a CPT that is a member of two separate taxonomies. On the taxonomy archive page for one of the taxonomies, I need to further group and sort on the second taxonomy like so: ...
0
votes
1answer
118 views

Allow filtering of loops for all categories

I want to give the option to filter the index page and every archive page for a category by things like newest, top-rated, most-viewed. I know how to filter a loop for each of those but I need a ...
0
votes
1answer
123 views

Issue with sidebar widgets not showing when I do custom queries

I'm having issues with this. I have 2 while loops, each getting different custom post types. They both work fine, except, my sidebar content i.e. widgets, is not appearing. I think this is because ...
2
votes
3answers
921 views

Pagination on custom query

I'm using the following code with query_posts to put together a custom search: $args = array( 'post_type' => 'species', 'meta_query' => $meta_query, 'tax_query' => $tax_query ); ...
2
votes
0answers
1k views

query_posts with a custom post type, a meta_query and sorting by post date?

I've searched the archives and found questions similar to what I need, but haven't found exactly what I want. I've got a bunch of products that are sorted by a meta_key of country, and I'd like to be ...
0
votes
1answer
404 views

Why would post_type be ignored in this query?

In the following query, post_type seems to get ignored resulting in display of all posts from my installation. What have I done wrong? <?php function filter_where( $where = '' ) { $where .= " ...
1
vote
1answer
2k views

pagination not working for category.php (custom post types in categories)

it works everywhere on my site but it isnt working in category.php. When i click page to it goes to... domain.com/category/cat-slug/page/2 by the way this is showing custom post types within certain ...
1
vote
1answer
3k views

Dynamically excluding current page id

I'm attempting to create a "related posts" section on pages using query_posts. I'm wanting to use this simply because we want to show random posts from one category on one page, so a plugin would be ...
0
votes
1answer
167 views

query_posts call sets is_home() to true

I have a custom home page (home.php). I want to show the original home page's posts on /blog/. I created a new blog.php file, with Template Name: Blog, added query_posts('numberposts=5&paged=' . ...
0
votes
1answer
2k views

show all in query_posts on category.php?

I want to be able to switch back and forth by clicking an anchor tag preferably, between showing a subset of posts and showing all posts, the code I am using is: query_posts($query_string . ...
2
votes
1answer
126 views

Can ordering post list by meta_value cause performance issue?

For some code refinement and to add new features to my plugin, I want to display posts ordered by specific meta column value like this; query_posts($query_string . ...
1
vote
1answer
268 views

Display all posts that were published before full post on single.php

The way I would like my blog to work is a user clicks on a post that was published on 12th March 2012 (for example) they get taken to single.php where the content of that post is displayed as normal. ...
0
votes
2answers
58 views

meta tag placement for google verification

Please tell me in simple terms starting from the dashboard of a 3.3.1 webpage how to get to the place where I put this meta tag google is requiring in order to verify my site. If you start with on ...
2
votes
3answers
6k views

Return all custom meta data for one custom post type

I've set up a custom post type which has three custom meta fields: name, latitude, longitude. Each post already shows the name on an integrated map based on it's latitude and longitude. I now would ...
0
votes
1answer
151 views

How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?

I need to know the most efficient method to grab 3 pieces of data from from multiple posts: Post title Thumbnail Custom Field I am attempting to build a Google map of posts using data stored in WP ...
0
votes
2answers
1k views

get_meta_data within a loop

I'm trying to make a simple widget that displays a list of posts, and is followed by some metadata from each post. Here is my code: $eventdate contains the metadata i need to retrieve. ...
1
vote
1answer
362 views

My post repeats itself on the second page [closed]

Hey the way i have my index coded is that it shows one full post and the rest of the post are excerpts, but when i click previous the 2nd page shows the same post from the first page, what can i do to ...
1
vote
1answer
169 views

get custom post type

I am using this code to get custom posts in rows. <?php query_posts('posts_per_page=72&cat=' . $cat . '&order=ASC'); $columns = 5; $increment = 0; ?> <table class="cat"> ...
0
votes
1answer
97 views

Notting but the latest post content keeps on being loaded

Im loading post into a content area via ajax but the latest post is the only one that loads, any one encounter this and manage to fixed it, if so please enlighten me. <div class="content"> ...
1
vote
1answer
227 views

Custom post types instead of regular post's categories in a page template

So I got this template which originally queried regular WP posts by their categories so that the page would show a category name for "category 1" as a headline and then posts from that category below ...
1
vote
1answer
241 views

Category Foreach keeps looping?

I'm using the following code to acquire all the child categories of a category and displaying the child posts of the child categories. <?php $cats = get_categories( 'child_of='.get_query_var( ...
0
votes
2answers
179 views

why to use query_posts() in custom page?

Hi i am new in wordpress and want to know about query_posts() function. If there is index page or home page than there is no need this function to display post but if i made custom page than there ...
1
vote
1answer
163 views

Show Blogroll of another WordPress site

I am managing a couple of WordPress sites, all hosted on the same VPS, and the client would like the homepage blogroll of Site A, that the own, to appear on Site B that the also own with the same ...
1
vote
1answer
10k views

How to show related posts by category

In my gallery site i want to show other pictures under the current picture (in single post). I seen more codes but it i asks to specify the category, but i dont want want specify the category manually ...
2
votes
1answer
426 views

Order by value in serialized custom field

Quite a pesky problem here. I've taken over a site that contains multiple information, serialised, within a custom field. For example: if ($new_query->have_posts()) : while ...
0
votes
1answer
417 views

Count custom post type based on two meta data

I am trying to count my custom post type called 'appointments' that match two meta data values . The meta data keys are 'location' and 'timestamp' So in english my query is: How many appointments ...