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)

0
votes
0answers
73 views

Publish specific category posts to specific pages

I'd like to have many different categories of posts. And many "blog template" pages. And when i create a new post of a specific category and see it posted only on specific pages. Is the only way by ...
0
votes
0answers
54 views

Repeating a loop after x amount of time

I'm new to Wordpress and PHP and would really appreciate a little pointer regarding a problem I can't solve: I have a Wordpress site and in my Homepage I have a section that when the page loads ...
0
votes
1answer
241 views

While loop with bootstrap [closed]

Is it possible to do a while loop with Accordion from bootstrap ? I am trying to make a FAQ section with the repeater add pro add on from advanced custom fields. All the questions show up but they ...
0
votes
1answer
27 views

show category name before first posts in each category

I want sort posts in the loop by category and before first post in each category display category name. For example: Category 1 Post Post Post Category 2 Post Post Post Post ...
0
votes
2answers
54 views

WP_Query a custom field value bringing back 0 results

I am trying to do a query to grab all the pages that have the tickbox checked "feature_on_front_page" which has the value "featured" with label "Featured". I added this checkbox with ACF. My query ...
0
votes
0answers
24 views

How to move posts in featured category on top and keep pagination

I want to move every post from category_id = 11 and 10 on top of the list and then query every other post which is only in 10th. I thought that making two loops will do the trick but there is a ...
1
vote
2answers
151 views

Exclude category by slug for for each loop

I am trying to exclude some categories from a for-loop. <?php $categories = get_categories(array('exclude' => 'apps, windows')); ?> <?php foreach ($categories as $category) : ?> ...
0
votes
1answer
19 views

How to sort posts in archive loop

I need to sort posts using this loop, is an archive page (pc-archive.php) for a CTP named "PC". Tried with <?php while ( have_posts('order=desc') ) : the_post(); ?> but no luck... ...
1
vote
2answers
94 views

Looping through posts per category gives same posts for each category

For a specific section on my website I loop through some categories and get the three latest posts in that categorie and list them. Like so: <?php $categories = get_categories(array('exclude' ...
1
vote
1answer
134 views

Any number in meta key (wp query)

I have such a query. The field modules_%_text is advanced custom fields flexible field where % should stand for ANY ROW number, it seams that it should work like that, however it's not. What i'm doing ...
2
votes
1answer
13 views

How to check for specific content in comments in the loop

I'm using the following conditional code to check if any comments on a given post contains a certain string. -The word 'CHANGES' in this case. I have it working if I specify the comment_ID directly, ...
0
votes
0answers
92 views

Bootstrap tabs inside forloop

I'm using bootstrap tabs with custom icon for each tab, I used wp_terms() to get taxonomies and with for loop print the title of them for each tab. but how can I add the specific class for each icon ? ...
2
votes
1answer
2k views

save_post + insert_post = infinite loop

I'm trying to automatically create a new post when a post containing a certain custom field is saved - hooking an insert_post function into save_post. This generates an infinite loop. I found some ...
0
votes
1answer
51 views

Get most recent post for every term in a given taxonomy type

I'm looking for an efficient way to retrieve the most recent post from every term for a given taxonomy type. I found this question, which provides the same solution I came to on my own: $terms = ...
3
votes
1answer
156 views

the_content and wp_link_pages

Many plugins seem to be adding a filter/action hook to the_content to display related posts, advertisements and such. The problem is I these appear before the post pagination so it the pagination is ...
0
votes
1answer
56 views

Pass the_post() as a parameter

I would like to take the following code sample <?php while ( have_posts() ) : the_post(); ?> <h2><?php the_field('title'); ?></h2> <p><?php the_field('desc'); ...
0
votes
1answer
407 views

get_posts() forcing ignore sticky posts on main loop

I have a custom query using get_posts() that besides ignoring sticky on its main query, ignores sticky posts on main loop. Reading around I've found that get_posts() have some trouble with sticky but ...
0
votes
1answer
6k views

Twitter bootstrap carousel multiple items in carousel

I'm pulling in posts from a specific category using twitter bootstrap carousel rotator. I've looking into double loops but I can't figure out how to implement it. Here is my loop: $query = array( ...
0
votes
0answers
46 views

Get posts of specific post format, extract youtube link and use ID for image thumbnail

I am looking to query four posts of which I'll display the title and the video thumbnail. Something like this maybe? $args = array( 'tax_query' => array( array( 'taxonomy' ...
0
votes
3answers
61 views

Cant insert wrapper div into index.php

I'm having an issue inserting a wrapper div into my php index file that we're using for the front page of the site. Right now it looks like this: And it needs to look like this: I'm aware this ...
0
votes
0answers
62 views

Pagination on custom post types

Pagination works in the front page but in custom post type page it doesn't appear. Post type: add_action('init', 'portfolio_register'); function portfolio_register() { $args = array( ...
1
vote
1answer
51 views

<!--nextpage--> as a shortcode within the loop?

Anyone implemented this successfully? I want to include the <!--nextpage--> within a single post loop as a shortcode. I tried to echo it, the tag shows up but the post doesn't get divided into ...
-1
votes
1answer
91 views

tax_query not working properly with get_posts

Here are my args: $args_home = array( 'post_type' => array('news', 'jobs'), 'posts_per_page' => 12, 'meta_query' => array( array( 'key' => '_thumbnail_id' ...
0
votes
0answers
58 views

the_title() Returns the page title instead of the post

I'm using a custom page for listing my posts, now using the loop and the_title() returns the page title instead of the posts. My loop is a simple: <?php if (have_posts()) : ?> <?php while ...
0
votes
1answer
90 views

get_the_title() is returning results from previous loop

I'm attempting to loop thought a custom post type (artists), then each category, then another custom post type (story) which has a relationship with the artist. The issue is, the function ID ); ?> in ...
1
vote
1answer
56 views

Sanitize Custom Field Value in Meta Query

I'm using the pre_get_posts hook with meta_query args to filter an archive loop by dates. Basically, there is a custom post type of "events", and my users type in a date as a custom field for the ...
0
votes
1answer
23 views

How can I modify this code to iterate over an array of categories?

I'm setting up a query for a series of 12 classes that will last a week each. There will be a morning session and an evening session. I'll have two different loops in the template to break those ...
0
votes
1answer
80 views

How to exclude or filter password protected posts when using next_post_link() previous_post_link

I'm using next_post_link() and previous_post_link() in my theme. I excluded my password protected posts from the loop. They only appear if you enter the URL of this specific post. But, the problem is ...
0
votes
2answers
72 views

Skip posts, but keep posts per page

I'm running through a normal loop on one of my templates, and it displays a list of upcoming events with dates. I'd like the events that have passed to stay active, but not appear in my list of posts. ...
0
votes
1answer
44 views

Give each posts in a loop a number in sequence

In my homepage, I have 10 latest posts. I want to display numbers starting from 0-9 in each post. 0 1 2 3 4 5 6 7 8 9
0
votes
0answers
32 views

Custom loop layout. How can I do that?

This is the structure of the loop that I want to do. There are 2 thumbs sizes: 1. thumb-square 2. thumb-tall HTML structure: <div class="main-wrap"> <div class="col-left"> ...
0
votes
1answer
25 views

Set Transient on CPT

When I add set_transient code to my cpt query, I get a Fatal error: Call to a member function have_posts() on string ... on line 30 Line 30 is basically: if($graduate_student_query->have_posts()) ...
0
votes
1answer
1k views

Group posts by date with a list

I want to set a group of posts grouped by date as a list. Below is what I would like to have: Day... <ul> <li><a href="#">Lorem ipsum</a></li> </ul> Previous ...
0
votes
1answer
84 views

Wordpress loop not working on static front page

I have a static wordpress front page. I want the code that works on my regular blog template to work on the homepage too. Currently, it only shows one post. The code in the main index.php is this... ...
1
vote
2answers
100 views

Get next and previous 3 posts in a term in single post page

I have a the following Custom post type: episode Custom taxonomy: series sub terms real deal -> season 1, season 2, season 3, etc. The terms are hierarchical, and the entire thing is ...
0
votes
0answers
50 views

Strange problem with wp_get_attachment_image_src database (db) query count

I have a purchased theme that has a custom WordPress loop in it that looks for image attachments via wp_get_attachment_image_src. It does this by doing the following: $image = ...
1
vote
2answers
7k views

Why WP_Query('showposts=5') shows only 1 post?

I am trying to do a simple query to get the latest 5 posts into an unordered list, but this is only showing 1 result even though I have several posts. I even did an offset, but it shows the next post ...
0
votes
4answers
884 views

Hide featured post on second page

I have a index.php with a featured post and a number of other posts and the standard wp_pagenavi at the bottom. I'm using the 2 loops from the wordpress codex like this: <?php $my_query = new ...
0
votes
1answer
95 views

Create multiple sections for all categories and then queries all the posts for each of those categories

I'm trying to find to find a way to create a loop that queries all categories and then the posts under those categories. I am using a custom loop to display my posts and I'd like to have it follow ...
0
votes
0answers
26 views

How to include posts from one category, into a separate category of posts?

How would I insert one category of featured posts into another category of posts? So, the second, fifth and eleventh are posts from a completely different category. Hope the below illustration makes ...
0
votes
0answers
14 views

Loop within category's posts

I'm trying to figure this out since a couple of days, and even though it should be a quick and easy thing, I couldn't find any workaround. I've 4 categories, and each of it has between 10 and 40 ...
0
votes
1answer
71 views

Best way to check if a post with specific meta exists

I am building a function in wordpress that reads an XML file and imports 100-500 events as a post type to wordpress. The events have a lot of meta data that is saved as post meta. One of the meta data ...
0
votes
0answers
26 views

Get link to another taxonomy from a taxonomy list

I'm currently working on a site for an artists directory. I have two custom taxonomies; Artists and Artist Genre which will be tied into a custom post type of artwork. I can get a loop to list out ...
0
votes
2answers
29 views

how do i make this loop work

Apologies I am a PHp beginner and I have no idea why this loop is not working on my tag.php page any help would be welcome. <?php get_header(); ?> <div class="posts"><!-- BLOG --> ...
-1
votes
1answer
21 views

How to do query_posts on tags pages

So I am using the tags.php on my WordPress site to create special featured pages; what I would like to do is create a featured area on the index of every page that contains the first five posts. I ...
0
votes
1answer
591 views

Create a custom taxonomy template that loops through child categories in term order?

We're building a site that sells Biking Gear We're using the Genesis Theme Framework, and developing a custom child theme. It has a Custom Post Type for Products, made with the "Custom Post Type UI ...
0
votes
3answers
1k views

a-z list, categories and sub categories in loop

I'd like to list my categories in a loop from a-z, the code i currently have just keeps repeating over and over im not sure what the problem is but the format should look something like. Parent ...
0
votes
1answer
35 views

Multiple Loops on a Page Without Duplicates

I have tried many different versions of this and nothing seems to be working for me. I want to display single posts of a custom post type (portfolio) each in its own div. I don't want any duplicate ...
0
votes
0answers
32 views

How do I filter out certain posts from the loop while keeping total number of posts displayed the same?

I'm building a theme where a number of posts would be featured above the cut, while the rest of them would be displayed below. It's fairly easy to filter out the featured posts from the loop - I ...
0
votes
1answer
29 views

Modify loop output for a specific list of categories

I'm trying to modify the output of a loop on an archive page for a specific list of categories. Normally this loop outputs the Title, Author, Date and does so for every post in that given category. I ...