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
1answer
522 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
112 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
767 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
437 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
593 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
219 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
769 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
179 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
108 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
670 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
394 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
450 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
254 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
410 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
241 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
730 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
291 views

Show css depending on activity type in BuddyPress activity-loop

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
115 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
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
674 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
17 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
61 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
32 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
51 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 ...
1
vote
1answer
55 views

Custom Post Types strange pagination problem

Have a strange problem with pagination, the query work fine when I'm in homepage, but if click for the next page I get a 404 error. Disabling permalinks settings, I saw that in the query string (when ...
1
vote
1answer
19 views

Obtain page data and use regular loop

Is there a way to obtain the data from a certain page outside the regular flow, more efficiently than via get_post($id)? I know that I can get for example the title with $post = get_post($id); $title ...
1
vote
1answer
37 views

How to display posts by vote count and if no value continue with latest posts with no votes?

Maybe someone can help me with this. I want to display posts by votes. Users can only vote up. So what I want is - the most voted posts by vote count on top and then latest posts with no votes. The ...
1
vote
0answers
29 views

How can I load posts starting from, and including, the current post?

I'm loading some posts using this argument: $args = array( 'category__in' => $catID, 'category__not_in' => 1, 'posts_per_page'=>10, 'date_query' => array( array( 'before' => ...
1
vote
0answers
59 views

How to show a post if was published less than two hours ago?

I want to show posts only that were posted less that 2 hours ago and have the custom field "¿directo?" with the value "Sí". These are my progresses, but they don't work: Functions.php: function ...
1
vote
1answer
69 views

List users by sum of all their posts' custom field values

So I can do this by user, individually, but I can't figure out how to put it in a foreach loop. What I want to do is output something like this: Author, Miles Where miles is the sum of every ...
1
vote
2answers
126 views

Load wordpress content in other domain

I've made some researches on google but can't get the right answer. I need to get my wordpress loops outside a domain using php file. For example: I have a website hosted with www.mysite.com using ...
1
vote
0answers
22 views

Does page.php need the loop? [duplicate]

Simple question. Does page.php need the loop? The Loop 'loops' through several pages/posts/content. However the page.php template only has 1 page. There's nothing to loop through. I noticed that ...
1
vote
0answers
37 views

Sort results by groups of numbers and letters

I have this code: <?php $letter=' '; query_posts( array ( 'orderby' => 'title', 'order' => 'ASC' ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <ul> ...
1
vote
1answer
33 views

How To Get Posts With A Specific Word

How to retrieve posts with a specific word in the loop. For example, I want to retrieve all posts with the title of the profile post (custom post type): ...
1
vote
1answer
38 views

Echo all category names, apart from one

I've got this simple code, that creates breadcrumbs: function the_breadcrumb() { if (!is_home()) { echo '<a href="'; echo get_option('home'); echo '">'; echo ...
1
vote
2answers
36 views

Listing subpages title and content and styling the first iteration differently

So for now, every iteration looks the same and it's been a while since I dealt with php so could you help me? <?php $pages = ...
1
vote
2answers
67 views

Best way to assign post position in a news site homepage? (no categories, no sticky posts)

I'm currently redesigning a local news website. The old design used a whole lot of categories to handle the position of the content in the static homepage as in "top news", "middle box", "left box" ...
1
vote
0answers
187 views

Shortcode in posts called by ajax is not working

I am using ajax to load content of post. Functions like the_title() works fine, but unfortunately the_content() doesn't returns any shordcodes( gallery nor tablepress ) data. here is my code: ...