The core of the WordPress query, the loop offers an easy way to access post information and display it on your website.

learn more… | top users | synonyms (3)

1
vote
3answers
3k views

Calling custom fields for pages (not posts)

I'm trying to place a small code in my template header.php file. I want to get a custom field value. I'm trying to call custom fields from current page outside of loop, btw. I have no problem doing ...
1
vote
1answer
235 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 ...
1
vote
1answer
97 views

Sort posts by most recently modified

Is there a way to list posts in the order in which they were modified? For example; A user posts 5 posts (#1 being the oldest and #5 being the newest), by default they would be listed with #5 being ...
1
vote
1answer
477 views

how do i remove posts from a WP_Query so the pagination is right?

I'm using a custom post type and showing 20 of them per page on the homepage. I'm using QP_Query. One custom field for the custom post type (called mixtapes) is a checkbox called "unreleased" (set ...
1
vote
1answer
256 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. ...
1
vote
1answer
673 views

Running a loop with a custom query string on a custom page template

I made a custom page with a template that is just a loop with custom query string for a list of posts from a specific category but when I view the page it only shows one post with the title being the ...
1
vote
1answer
631 views

posts_per_page & pagination conflict

I have a custom query to display my custom post type. posts_per_page set to '5'. In admin post per page set to '10' (settings => Reading => Blog pages show at most 10 posts) My template lists 5 posts ...
1
vote
1answer
637 views

Loop through child images of a parent for a Nivo Slider

I want to use a Nivo slider to cycle through the children of a parent page one by one, how can I do that? I have the following piece of code that grabs ALL the children of a parent page and displays ...
1
vote
1answer
382 views

Paginated HTML Sitemap

I've got to the point where I needed to break down my HTML Sitemap into several pages. It contained 2000+ links. The big layout was showing all post titles under category names on one page. I decided ...
1
vote
1answer
675 views

Why do themes have `while( have_posts() )` in templates like single.php?

Example: https://github.com/markjaquith/WordPress/blob/master/wp-content/themes/twentyeleven/single.php Isn't single.php's purpose to show single posts?
1
vote
1answer
542 views

How to hide all child pages with post_query?

i have a page template as start page(home.php). i use a 2 columns grid to display all pages on that home.php with title and excerpt. unfortunately also my child pages are shown and i can't figure out ...
1
vote
1answer
37 views

replacing the_autor or make callback

I'm looking a way tho change the the_author(); function in the loop, I have post meta data with the name of the user who posted. I need to do this: If the user is registered, show the_author();, ...
1
vote
1answer
113 views

Rating system and changing the loop

Alright, so I want to see who can help me implement this idea I have. I just want one single Icon next to a post. If you click it, then you "Heart" it or "Love it". The post has a counter to see how ...
1
vote
1answer
780 views

Check if date of post is yesterday

In a loop, I want to display "Yesterday" if the date of the post(s) are dated from yesterday... So here it goes: <?php if( date('Yz') == get_the_time('Yz') ) { echo 'Today'; } ...
1
vote
2answers
443 views

List posts AND custom post type by category

I found this question asked elsewhere, but it was unanswered, so I'm asking myself. I have a custom post type (Features) that shares my Categories and Tags with my standard posts. I'm listing my ...
1
vote
1answer
598 views

Is it possible to have pagination with an offset loop?

I am developing a blog page that requires 3 different post styles (Ie; one full page width with featured image and content, one full page width without featured image and the rest are half page width) ...
1
vote
1answer
221 views

Adding general page content to page templates

If I'm creating a page template, let's say for example one for a testimonials custom post type I've created, I think I have it figured out that if I do the following in page-testimonials.php: ...
1
vote
1answer
803 views

Custom post type multiple loop by taxonomy term

I would like to create one loop that lists the custom posts for each taxonomy term: Term A: Item Item Item Term B: Item Item Item I would like this to be totally dynamic so if I add a new term it ...
1
vote
1answer
180 views

Sidebar loop - Thematic Framework

I'm trying to add a sidebar loop to list 3 news post. I'm using thematic framework and since I don't find any hook to use I first write this function in functions.php function sideloop(){ ...
1
vote
1answer
109 views

How can I make the loop not count special post formats towards the post count?

I have WordPress set to display 5 posts per page, which is what I want. However, I'm now starting to use the new post formats (link, status, quote etc.) but I would these to not be counted towards the ...
1
vote
1answer
184 views

Combining action and filter?

I tried to set up different video oembed size for content and sidebar. I can set up video size with embed_defaults filter. But this filter works for the whole site and I need to have smaller video ...
1
vote
2answers
5k views

get custom post type by tag

Is it possible to retrieve post entry for a custom post type by tag, I have been trying with the following code, however it just locks me into a infinte loop. <aside class="supporting_images"> ...
1
vote
2answers
5k views

WP_Query to get posts in a specific category and post format

I've been trying to utilize either WP_Query or get_posts to pull out the most recent post that's both in a specific category and of a specific post format. <?php $singargs = array( 'numberposts' ...
1
vote
2answers
683 views

Why do next pages load the same content rather then older articles?

For some reason, the 'previous posts' and 'next posts' on the homepage do not load previous posts, but rather the same posts that were on the main page. Why is that? I don't even know where to start ...
1
vote
1answer
399 views

How to pass the current content of $wp_query to a new page?

I am developing a Wordpress theme that uses a lot of AJAX. It is composed of two main pages: the index, which displays a list of posts, and a viewer (similar to single.php). When a post is clicked in ...
1
vote
2answers
468 views

Easiest way to show total number of subpages

I am making a portfolio site where each portfolio entry is a subpage of "Work". In my template, I am trying to say something like: worked on 15 projects and counting, where 15 is the total number of ...
1
vote
1answer
263 views

using the loop with a custom table

I have a table in my WordPress db called wp_featuredposts. How can I make a query to output the posts in that table into the loop on a custom wordpress page template?
1
vote
2answers
1k views

List custom taxonomy specific to one custom post type

I am slowly going mad trying to figure this out.. I want to list custom post type 'mobile_review' by custom taxonomy 'mobile_phone', as multipe custom post types share this taxonomy I need some way ...
1
vote
2answers
412 views

Display both standard posts in a specific category along with a custom post type in a single loop?

I'm building a content slider that needs to show posts from a custom post type called "Features," and also show standard blog posts that are assigned to a "Featured" category. I'd like to do this ...
1
vote
2answers
242 views

How do I order my loop query?

I have a table in my database containing vote a tally I'm trying to order posts by. screenshot: the table I've tried something like this, which brings up all the voted posts and pagination okay but ...
1
vote
1answer
750 views

Add pagination to my custom loop [duplicate]

Any tips on fitting pagination into my loop below and I owe you a beer or two. I've worked out how to pull the top rated articles by vote from a custom plugin, and lay it out with a count, but ...
1
vote
1answer
129 views

How can I create a legend (Key) like the one in the footer on WordPress StackExchange

Ironically, Wordpress StackExchange has the perfect example of what I'm trying to do. At the foot of every page here is a key/legend of associated sites with a colour reference for each one. I need to ...
1
vote
1answer
294 views

Show css depending on activity type in BuddyPress activity-loop [closed]

I was wondering if anyone knew of a way to show specific styles to the activity loop depending on the activity type? This is what I had an idea of: function mycustom_act_type() { if ...
1
vote
2answers
6k views

How do I get the title of a category in a custom loop?

I am using the following code to display a list of posts within a category, but I want to display the title in it's own h2 tag above the list. <ul class="subcats-list"> <?php $weightloss = ...
1
vote
1answer
119 views

It is possible to encounter horrible bugs if I place a main loop that uses `query_posts` right above the main bbPress loop?

This is the code: <?php get_template_part( 'pagination', 'bbp_replies' ); ?> <?php query_posts('gdsr_sort=thumbs&post_type=bbp_reply&posts_per_page=2'); ...
1
vote
1answer
1k views

Dynamic sidebar nav with current page highlighting

My sidebar loops through all of the child pages based on the parent page. For example, if you're in the "About" section you'll only see "About" child pages in the sidebar. My problem is that I have ...
1
vote
2answers
2k views

Content/Excerpt length control for a specific loop?

Is it possible to control the length of the content or excerpt for a specific query/loop? I have come across the following code, but this changes the length for all excerpts, I want it focused on a ...
1
vote
2answers
6k views

How would I create a shortcode to display a custom post within a page or regular post?

I would like to create a shortcode that will extract information for a custom post, and display it within a Page or regular Post. Specific use case: I have a custom post type "Film" for a film ...
1
vote
1answer
1k views

Paging doesn't work?

I have my own custom post type, and 15 items there. This code shows all the items: <?php $loop = new WP_Query( array( 'post_type' => 'my_post_type', 'posts_per_page' => 15 ) ); while ( ...
1
vote
1answer
695 views

Pagination Issues using WP_Paginate Plugin

So I have read more posts and articles about this issue than I care to admit and still nothing I can find works. Here is the issue - I can not get the pagination to advance and it shows all the same ...
1
vote
2answers
4k views

Strategy to get post meta for use outside the loop

I need to know solutions for the question above. There are cases, when we need post meta information outside the loop. Let's say, I'm developing theme that will display ads from certain vendor on that ...
1
vote
0answers
33 views

Multiple Loops Meta Data

I am now trying to figure out how to create the functions/ loops to pull my data from custom post types. I have two post types(keys): And I need to pull the data from both to run my functions. ...
1
vote
1answer
16 views

Modify main loop in taxonomy archive page

Is there a way that I can modify the main loop in a single taxonomy template, but leave it untouched in every other template? In this case, I have a custom post type called "Events" which in turn has ...
1
vote
0answers
42 views

Divide Loop Into Days & Categories

If you could help, I'd greatly appreciate it, because I'm halfway there, but I'm currently stuck! The site I'm working on needs to have it's posts, within the loop, divided up by days, and then under ...
1
vote
0answers
18 views

How to get rid of the strange sizing of links around posts? [closed]

I am currently running into a bit of a problem on my Wordpress site. I am designing a theme using the Bones framework, and after working for a while I have discovered a weird bug with links. Any time ...
1
vote
3answers
73 views

The Loop in Static Page

I have some questions about the loop. I'm using "twentyfourteen" theme as an example. I'm creating 2 php files with basic loop. One is home.php, and one is a template page called sample-page.php . ...
1
vote
0answers
34 views

WordPress Rewriting the DOM?

WordPress 3.9.1, Bones Theme. I'm setting up an archive page for regular 'ol blog posts. The theory is to wrap each post's information in a permalink. Such as: <?php if (have_posts()) : while ...
1
vote
1answer
24 views

How to use current_post to open a new unordered list every five posts

How can I add a break dynamically after 5 posts have been display to create a list of post titles? <div class="col-sm-2"> <ul> <?php $args = ...
1
vote
2answers
40 views

How can I paginate this?

Been trying to use the pagination functions in wordpress with this code <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_status' => 'pending', ...
1
vote
0answers
54 views

Custom Theme With Custom Loops

There are so many different questions on how to make pages show page numbers at the bottom but I can't seem to use the concepts explained in those to solve my own problem. I know some PHP and I've ...