Viewing 1 to 10 of 12 items
Tag Archives: query posts

Query both posts and pages within a loop

Taken from here: http://www.devdevote.com/cms/wordpress-hacks/use-sql-querys-in-the-loop-with-template-tags/ The problem I want to use SQL-querys within the WordPress loop and still be able to use the template tags. In this example I want both posts and pages within the loop. How can I do that? In both query_posts and WP Query I can only get specific posts OR pages, not  Full Article…

0

Query only posts with thumbnails

The issue with the coide for displaying only posts with thumbnails in the past has been that you query the posts type and then put a ‘if has post thumbnail’ conditional in the loop. This means that if you wanted 12 posts and that how many you get in the query, maybe only 6 have  Full Article…

0

Custom post types not showing up in queries and search results

If you can’t get Custom Post Types showing up in a query you should make sure that if you aren’t specifying a post that that you specify any –  post_type=any It’s also a good idea to do a query reset because there are many factors that can affect your queries.

0

Query a random post

Here’s a random post snippet I used on teh Better For Business website to feature a different Advisor on each page load.

0

Get Posts With A Specific Custom Field & Value

Add the query_posts() function just before the Loop. Change the meta_key and meta_value accordingly. The example shown below will get posts with custom field “review_type” with value “movie”.

0

Multiple Loops without Duplication

If you need to break display your posts in different sections (like in Magazine themes), where you want to display a fixed number of posts first, and the remaining later, you can use this code to make multiple loops (with offsetting the fixed posts in the later loop). The first loop that will pull and  Full Article…

0