Linked Questions

1
vote
1answer
2k views

query_posts() vs get_posts() multiple loops [duplicate]

I have a template which initially had one single loop and it was using query_posts, I added 2 more loops using the same method, However after reading allot about these it was concluded that I shall ...
0
votes
0answers
15 views

Looping through a custom query makes WordPress assume another template [duplicate]

I am calling this code from my custom sidebar, in order to get related postings from the same category: query_posts(array( 'cat' => get_category_id(), 'showposts' => 5, 'post__not_in' ...
72
votes
3answers
39k 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 ...
16
votes
4answers
8k views

Is it necessary to use wp_reset_query() in a WP_Query call?

I'm using the following code to retrieve posts: <?php $featuredPosts = new WP_Query(); $featuredPosts->query('showposts=5&cat=3'); while ($featuredPosts->have_posts()) : ...
9
votes
1answer
6k views

How to fix pagination for custom loops?

I have added a custom/secondary query to a template file/custom page template; how can I make WordPress use my custom query for pagination, instead of using the main query loop's pagination? Addendum ...
7
votes
4answers
2k views

the_date() not working

I am using wordpress 3.2 and I did a query post like this: <?php query_posts("posts_per_page=1post=type&page=post_parent=10");?> Then I try to echo out the date of this post I queried ...
6
votes
4answers
3k views

Is there a flowchart for wordpress loading sequence?

So like wp must load series of files from, index.php -> ... -> wp-header.php -> ... ->functions.php ...and so on upon execution. Also there must be a similar flowchart for functions ...
9
votes
3answers
8k views

Order by meta value or date?

Got a custom field called startDate but its only on a few events. I was wondering if it isn't set for a post I could use post_date to generate the posts list? // if meta_key _postmeta.startDate isn't ...
7
votes
2answers
1k views

Looking for WordPress System Diagrams

I am looking for WordPress chart/diagram system design. I found only the template hierarchy diagram, but it's only part of the system. source: ...
5
votes
1answer
6k views

How set featured posts using checkbox in post edit screen?

I want to make selecting a featured post is just by checking a checkbox in edit screen AND be able to retrieve these featured articles from only specific category ? in short what I'm looking for : ...
5
votes
1answer
6k views

Get all image from single page using this query

I'm having some trouble with this sample widget code. I want to get all images (Minus the post thumbnail) from a page called "Gallery" but for some reason this is pulling all uploaded images from the ...
1
vote
1answer
7k 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 ? ...
4
votes
2answers
4k views

query_posts() in function makes global $wp_query out of sync?

This has me stumped for a while already. Either I am missing something very obvious or something very not obvious. I am also not entirely sure if this has something to do with WP or purely PHP ...
1
vote
4answers
3k views

Wordpress not respecting template hierarchy (fetches index.php instead of single.php or page.php)

I've encountered a strange error while developing a custom theme. After finishing editing the template for a custom post type single view, I passed onto working at the template files for pages and I ...
3
votes
1answer
2k views

WP_Query vs get_posts

I have read a number of questions on SE regarding these but I still can't figure the exact difference wrt usage. Would it be true to say that I would probably use WP_Query for the majority of ...
2
votes
2answers
1k views

“pre_get_posts” firing on every query

How can I change arguments for the main query only, and not affect other queries? add_filter('pre_get_posts', 'custom_post_count'); function custom_post_count($query){ ...
2
votes
2answers
2k 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 ...
2
votes
1answer
1k views

Is it necessary to reset the query after using get_posts()?

Is it necessary to reset the query after using get_posts() ? I have been looking at this page and I don't see any reference to get_posts() ... I can't make it out for sure from this page either. I ...
0
votes
3answers
3k views

Problems excluding a custom post-type from the loop

Morning all, I'm having some issues with excluding my custom post-type 'events' from my index.php loop for my Blog page. I simply want to display the posts from my actual Blog, which I assume come ...
2
votes
2answers
2k views

How to make multicheck for post/page meta box

Please help me understand how to make Multicheck type for metabox. Search for all internet and nothing. Thanks. UPDATE @Jan I have a headache from this function. I dont know whats wrong.I'm ...
1
vote
2answers
2k views

Query for multiple post types does not work

I'd like my frontpage to display a list of my lastest blog posts merged with my latest "Products" custom post type posts. From the documentation i gather this should work: query_posts( ...
5
votes
2answers
936 views

Differences Between WP_Query() and get_posts() for Querying Posts?

What are the differences between using WP_Query() and get_posts()? Which is better to use in what case and why?
0
votes
2answers
2k views

Exclude current post from loop

I have a custom post type for accessories. When you view the post it also shows related posts. It looks great, but it also shows the current post within related posts. Is there a way to exclude the ...
0
votes
2answers
2k 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 ...
0
votes
2answers
1k views

Am I using get_posts wrong?

I have <?php $folioPosts = get_posts(array('category_name' => 'portfolio', 'numberposts' => 3)); if ($folioPosts->have_posts()) : foreach ($folioPosts as $folioPost) : ...
0
votes
2answers
2k views

Why this code causes infinite loop?

Hi all I have this template page which get the page's post and then a list of posts from the category news. <?php /* * Template Name: News & Info */ get_header(); ?> <div ...
1
vote
1answer
2k views

How to display related posts from same category?

Is it possible to display related posts from same category as the current post?
3
votes
2answers
1k views

Archive by Year

After some searching I haven't been able to find a answer to what I'm trying to archive. I'm trying to set up an archive page with accordion panels that hide/show posts from a given year with links. ...
0
votes
3answers
2k views

current-menu-item not added on page showing custom post type (rendered with archive template)

I have setup a custom post type called 'expertizeom' I have setup a page called "expertize" and added to my custom menu (site main nav). The page is rendered with an archive called ...
0
votes
2answers
1k views

Multiple Category Query

Is it possible to display a wordpress category page but have it pull posts from mulitple categories? For example, let's say I need to pass in params for cat_id in this fashion ...
0
votes
1answer
3k views

Sub-loop / nested loops Best Practices

I'm trying sort through the morass that is WP documentation, and just need someone to clear up the use of the term "The Loop" and how it relates to subloops. My understanding of "The Loop" is that ...
0
votes
1answer
2k views

When to use Wordpress loop or Foreach loop?

Under what circumstances would you, (should you?) use a foreach loop, instead of the wordpress loop. I have no real coding need, but I'm curious. What's good practice here? Should I: ...
0
votes
2answers
2k views

Displaying related posts in a custom post type by a custom taxonomy

I'm trying to display related posts by a custom taxonomy (product_tags) in a custom post type (products). The following code works, but it ignores posts_per_page. Any ideas? global ...
0
votes
2answers
3k views

Show posts from category specified using a custom field

I have a post that shows the titles and excerpts from a specific category underneath the content. Currently this is coded into a specific template like this: <?php ...
0
votes
1answer
2k views

How to create a category and sub-category sorted blogroll with all posts?

I would like some help to post all the posts of my website into a blogroll sorted by categories and subcategories. The end-result HTML I would like to see displayed would be something like this: ...
0
votes
3answers
2k views

How do I use wp_get_recent_posts?

I'm trying to display the title and excerpt of the most recent 8 posts on the sidebar. I'm getting a list where: All items link to the oldest post All titles are "id number of a post that should be ...
0
votes
5answers
1k views

Is there any way of changing the post order via user click?

Is there any way of changing the post order, posts number, etc via user click? The same way you can choose displaying questions by time and vote here at StackExchange. How to accomplish that?
0
votes
2answers
1k views

Check if meta key value already exists

Let's say that I have few posts with meta key "videoid". Value of that meta key is different for every post (and has to be different). When adding new post, how can I check if videoid with that exact ...
1
vote
1answer
767 views

Exclude custom taxonomy tag from loop

I have the following code at the beginning of a loop: <?php query_posts('showposts=3&cat=84'); ?> <?php $posts = get_posts('category=84&numberposts=3&offset=0'); foreach ($posts ...
0
votes
1answer
1k views

How do I make archives.php for one category only?

I have a basic archives.php file. I was trying to get it to display only posts from category 1. When I do query_posts('cat=1'), the URL is then ignored and all posts in category 1 are displayed. For ...
4
votes
1answer
1k views

Taxonomy menu with post count and multiple parents

I'm using WordPress 3.1.3 and trying to make a "product" menu with post count in each category. Like this: New Cars (4) BMW (2) Ford (1) Nissan (1) Used Cars (10) BMW (3) Ford (1) Nissan (6) ...
0
votes
3answers
703 views

how to get a different html for odd/even posts?

query posts if posts exist then begin the loop if post is even: <h1>title</h1><p>content</p> if post is odd: <div>its ...
0
votes
3answers
661 views

Split wordpress loop to multiple layouts

OK so I've searched a lot and couldn't find a straight forward answer to my question. I am simply trying to use one category loop that will display posts in a category page in a wordpress site. lets ...
0
votes
2answers
1k views

How to make multi -column, interesting home page in Weaver 2010?

(I am pretty new to wordpress - am a C++ developer, not an html/css coder, but I am trying.) I am having trouble figuring out how to make a home page that has blurbs about some of our products, etc ...
1
vote
2answers
831 views

WP_Query or get_posts?

When using the 'fields' => 'ids' parameter, is it better to create a new WP_Query in the code below rather than doing get_posts? How would the loop look if I used WP_Query? function ...
2
votes
3answers
1k views

Adding “latest from the blog” to the homepage

I have a big problem and no clue how to solve it :) I want to add a "module" to my homepage (static homepage, not blog posts) that will display the 2 latest blog posts in a very particular way and ...
1
vote
1answer
1k views

Wordpress Pagination Not Working - Always Showing First Pages Content

I am working on a website where I have a blog but I also have a custom post type to allow me to drop in some videos. I would like to use pagination so that if there are more then 9 videos displayed, ...
2
votes
3answers
457 views

Exclude category on blog list page

I've got a site with a News page (archive for category 'news') and a separate Blog page. When I make a post for the News page I select the category 'news'. So, on the news page you only see the posts ...
0
votes
2answers
2k views

Blog Page pagination not working, loads Page 1 each time [duplicate]

I don't know what to do here but pagination is driving me crazy! As you can see, "Older" points to blog/page/2 but when clicked, the site stays on blog/. I'm using wp-pagenavi for pagination. The ...

15 30 50 per page