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

2
votes
1answer
492 views

Search stores (custom postcode field) within 5, 10, 15 miles of user inputted postcode.. Code modification

I have been searching for a location search solution for wordpress.. The best semi-solution I have found is http://mondaybynoon.com/2010/02/22/store-locator-wordpress-pods The problem being is that I ...
2
votes
1answer
418 views

“NOT ONLY IN” taxonomy query operator?

I have multiple users adding content to restricted categories (using RoleScoper) in my WordPress setup that don't show up on the homepage (custom template with query_posts()). I'm looking for a way ...
2
votes
1answer
678 views

How to dynamically build a multiple taxonomy query loop within a post type's single loop?

This question is a little different then the others floating around here. The most similar one is "How to get the parent's taxonomy ?". I have a music cms setup that utilizes two post types: album ...
2
votes
1answer
157 views

advice on creating a 'related posts' query like the one used on stackexchange

One of the things that I most enjoy about the stackexchange website is the 'related questions' that show up on the sidebar when I am viewing a question (or show up as I am typing my question). It is ...
2
votes
0answers
50 views

WordPress query for most recent posts from multiple categories

I have 5 categories. I want to query each category and get a list of the most recent posts from them. I also only want single post from each category, with no duplicates. Is there a way to do this ...
2
votes
1answer
217 views

order by meta_value serialized array

Hi I'm trying to pull posts using the wp query. Just one problem--I am trying to sort the posts alphabetically by a certain meta_value. Thing is that this meta_value is a serialized array. Is there an ...
2
votes
1answer
944 views

Page navigation doesn't show when query category

Problem: when I do www.example.com?cat=4 or choose category through custom menu or from category widget it shows only first page without navigation at the bottom, where it supposed to be. It's the ...
2
votes
2answers
824 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 ...
2
votes
2answers
142 views

Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]

I am currently trying to perform a custom query on the authors page (author.php). I have two custom fields for posts that I want to query against (post_photographer and post_videographer). What I am ...
2
votes
2answers
100 views

Multiple instances of Featured Image Query

I have some custom code built into the header of my theme that gets the featured image from a post, displays the image and links to the posts permalink when clicked on by a user. The problem I am ...
2
votes
1answer
37 views

How do I query for a post by custom field?

I have a custom field called "song-id" and I'd like to lookup a post by a song-id value. Can someone give me the code snippet for it? (bonus: also looking for a code to use the permalink in the post ...
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 ...
1
vote
3answers
419 views

Insert all post IDs in new database table

I have a plugin which creates a new database table. Upon activating the plugin is there a way to insert all my posts ids into that table? Right now I'm using an action hook to immediately insert the ...
1
vote
3answers
7k 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
vote
3answers
14k views

Custom query with orderby meta_value of custom field

Aa you know, as of WP3.0 there are options for custom advanced queries, which is great. As of this, some query parameters of custom fields like meta_key, meta_value were deprecated for the new ...
1
vote
3answers
4k views

meta query not showing any results?

I'm trying to show result for a custom field that is not empty on a custom post type but getting no results? <?php if (have_posts()) : ...
1
vote
2answers
7k views

use query_posts to return a post OR a page by ID

I'm building a custom homepage for a client where they want to have a few changeable boxes to link to specific pages, or posts, within the site. I've added custom fields to the homepage so that they ...
1
vote
1answer
1k views

Query posts by custom post type and custom taxonomy

I am writing a custom loop query to filter through a custom post type and custom taxonomy. I have replaced any variables with static values for the purpose of showing you what result I want. $args = ...
1
vote
2answers
57 views

Integrating post archive wtih another source and preserving date ordering

I'm pulling posts from Instagram into the WP basic archive view; but I want things to display in order of date, and not screw up paging (too much). The outcome should look like this: BLOG POST JUNE ...
1
vote
2answers
91 views

How do you Query posts with nothing in common?

We can get multiple posts manually in a page, but that's generated in a template, AFTER the default query returned something else (page/post, etc) How do you query multiple posts in a public query, ...
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( ...
1
vote
2answers
2k views

Adding Variables to post query

How do I add custom variables to the wordpress query without having to hit the database twice. In the example below I want to add some meta filters. All this code works fine but I have been running ...
1
vote
1answer
5k views

Query Posts or Get Posts by custom fields, possible?

If I were to take a standard query post. <?php query_posts('post_type=payment'); while (have_posts()) : the_post();?> Only this time I would like to query the post by 2 custom fields that it ...
1
vote
2answers
240 views

greatest() function returns undefined property

I'm using the mysql GREATEST() function to compare two table fields and display in a loop either one with the highest integer value. The 2 fields consist of vote scores for posts: UP or DOWN. ...
1
vote
2answers
709 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 ...
1
vote
2answers
340 views

Next/Prev posts on same page

Hello WordPress Users, I'm stuck with a problem building my wordpress website and I can't figure out what to do about it. Currently I'm showing 2 posts form the category 'News' at the page 'News'. ...
1
vote
3answers
69 views

Trouble Making WP_Query paged

I'm using the query below in the index.php file as the main query, whenever I try to go to the 2nd page I get a 404 error, I tried using posts_per_page but to no avail. <?php $args = array( ...
1
vote
4answers
2k views

Order posts by custom field and if custom field is empty return remaining posts

I have an archive page ordered by a numeric value in a custom field. This returns the ordered posts correctly, but does not display posts that don't have a custom field. $paged = ...
1
vote
1answer
172 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 ...
1
vote
1answer
3k 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
2answers
2k views

Custom post type archive 404's with paginate_links

im using paginate_links function to create pagination on my custom post type archives, no matter what i do im hitting 404 errors when going to view page 2 (ie clicking to go on one page in the ...
1
vote
2answers
6k views

WordPress how to sort by meta value?

how in WordPress can I sort by meta value? In meta value I have "price" (float). I make this query, but always get "Sorry, no posts matched your criteria". $posts = query_posts( $query_string . ...
1
vote
2answers
1k views

Why is that gdsr_sort=thumbs (GD start rating plugin) only works with query_posts and not with WP_Query?

This correctly sort posts by thumbs vote (GD star rating plugin): <?php query_posts('gdsr_sort=thumbs&post_type=bbp_reply&posts_per_page=2&post_parent='.$post->ID); ?> <?php ...
1
vote
2answers
2k views

Select category in custom query

I'm sure this question is asked alot, but I cannot figure it out, since all the different ways to query posts are confusing me.. Here is my current code. How can I tell the code to only get posts ...
1
vote
1answer
120 views

Show Posts From Same Category OR Same Tag

Assume a post is categorized in "Fruit" and tagged with "Apple". The following code shows posts with category "Fruit" AND tag "Apple" $args = array( 'tag__in' => $tag_in, ...
1
vote
1answer
938 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 ...
1
vote
1answer
2k 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 ...
1
vote
2answers
279 views

making random query button using $_GET

Im trying to make my post random when i lick on my button using $_GET but it just keeps refreshing my page instead of refreshing with the random post. <a href="<?php echo $my_query; ...
1
vote
1answer
870 views

Order posts using a custom array

I have an array of post ids which I'm passing to query_posts using 'post__in'. My question is how can I use the order from my array rather than ordering by 'date' etc?
1
vote
1answer
2k views

how can i get posts from custom post type particular taxonomy category

I have registered custom post type Article in my template using register_post_type function. and i also having taxonomy category for this article posts. Here i want to filter the posts under ...
1
vote
1answer
574 views

Read More is not working in query posts

I have Query_posts in my page. the posts have tags to separate for read more, But while doing query posts it is pulling all content for <?php the_content('read more..');?>
1
vote
2answers
322 views

how can i use custom field in query post

I want to get all featured items using query post. featured is meta_key using custom field plugin. I tried bellow,but it failed $featured_item = new ...
1
vote
3answers
3k views

how to group custom post type posts by custom taxonomy terms

I would really appreciate if you could help me :) I'm very stuck and don't know how to proceed. I have a custom post type called event and 2 custom taxonomies registered for it: event_type with ...
1
vote
3answers
3k views

query_posts for child pages

I am having problems looking for info on the codex on how to query for child pages. It seems to be missing the reference for the available parameters
1
vote
1answer
1k views

Is it possible to query_posts using post__in and then Loop through them in the ordered they were queried?

query_posts( array ( 'post__in' => array( 5, 76, 21, 56, 3 ) ) ); I'd like to query the Loop using post__in and a set Wordpress IDs. I'd then like to run through the Loop in the exact order of ...
1
vote
1answer
1k views

How to insert content from another Custom Post type into Post?

Say I have a custom post type called "Performers". This gets populated with different bands/performers. These posts have a featured image as well as custom fields (mp3 file, facebook link, myspace ...
1
vote
1answer
8k views

using multiple meta_key and meta_value in query_posts

how can i use multiple meta_key and meta_value in query_posts? For example, I want to find multiple content with two different meta_key and meta_value. How do I do this? i using this code but not ...
1
vote
1answer
45 views

How can I sort homepage by a meta value?

I am trying to sort my home page posts by a custom meta value. I've been told I should use pre_get_posts but I seem to not be implementing it correctly. This is what I am doing: ...
1
vote
1answer
329 views

Perform query with meta_value date

I am trying to perform a query on a custom-type post using the value of a custom field. This field contains a string date: dd.mm.yyyy. The post type name is 'event' The custom field name is ...
1
vote
1answer
459 views

WordPress get posts by date without query_posts

I'm want to get posts from the last 30days in a sidebar but I don't want to use query_posts, is there a way to achieve this with the get posts function?