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
1answer
12 views

Loop returning only 1 result

I am not sure as to why when I run my loop only 1 result returns. Here is my code: <?php if ( is_front_page() && twentyfourteen_has_featured_posts() ) { // Include the featured content ...
4
votes
2answers
78 views

How to force excerpts / teasers in the loop

When I'm in "the loop" (archive pages etc.) how do I force teasers / excerpts for all articles, regardless of whether they contain the <!--more--> tag or not? Details: I'm starting off of the ...
1
vote
0answers
16 views

Conflict with get_posts and the_content

I have this snippet in my header.php to display a slider: <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 6, 'meta_query' ...
0
votes
1answer
33 views

WP_Query condition affects posts_per_page count

I'm trying to create a new WP_Query that displays the last 5 posts from cat 1 that doesn't have a thumbnail. This actually works: <?php $the_query = new WP_Query( 'cat=1&posts_per_page=5' ); ...
1
vote
1answer
34 views

Creating Accordians in Wordpress Theme

I am creating a wordpress theme in which there is a section "HUMOUR". In this section i've created accordians, in which the 1st accordian is in class="active" and rest don't. for e.g <dl> ...
0
votes
1answer
12 views

Need to add class to first element in a foreach loop

I'm pulling all attachments for this particular post and displaying them in a carousel. Problem is I need to give the first item a class of active so bootstrap carousel will work. Here is my loop: ...
0
votes
1answer
19 views

How to output thumbnail twice in a loop

ok I have a portfolio page. & I have two question: number 1: Every portfolio item has thumbnail attached. what I want is to print out the first thumbnail from the first post twice. One at the ...
1
vote
0answers
14 views

Question on how pre_get_posts fires

I have a pre_get_posts filter which I want to run on archive page(s) for custom post-type(s): if ( ! function_exists('filter_employees_archive_query') ) { function ...
1
vote
1answer
13 views

How to target thumbnails of the first post in the loop

ok currently my last post's thumbnail have an extra class, which were added by this code: <?php $extraLastClass = $loop->current_post + 1 === $loop->post_count ? ' main-image-porfolio-main' ...
-1
votes
1answer
16 views

Want to images load first then title in WordPress loop

ok I'm creating a portfolio page. I want all the images of the portfolio post stack together. & when visitors hover their mouse in any of the title the image ll show. for this I've created this ...
-1
votes
1answer
16 views

How to add class to the last image of the last post in a loop

ok, I'm creating a portfolio page, I want add a class to my last portfolio thumbnail. currently I have a class added to the div of the last portfolio item. I want to add it to the thumbnail, not the ...
0
votes
0answers
14 views

Add custom WP_Query after the first 3 posts

In my main loop I want to add a custom query after the first 3 posts. I managed to do this -- code will follow -- but I have one problem: instead of adding the new posts after the third post, my code ...
0
votes
0answers
15 views

Unexpected 'endwhile' [closed]

I'm beginner. Just starting creating my own template and faced with error on loop <?php get_header(); ?> <?php while ( have_posts() ) the_post(); ?> <p>example</p> ...
0
votes
0answers
8 views

Loop tags with specific design

Forgiveness for the title, I can not think of anything to describe it. First I have a basic loop: <?php $args = array ( 'category_name' => 'juego-de-tronos', 'orderby' ...
0
votes
1answer
22 views

Wrong post title displayed from loop

I'm building my own theme. I have a page set for my blog (with a template that I made) which I'd like to just display a few of my posts. It uses the following loop: <?php ...
1
vote
1answer
21 views

Display custom post on home page based on a metabox selection

I am trying to display an post to my home page based on a selection. What I mean is in the backend I have a custom post that has a metabox labeled Assign to Home with a drop down that has a selection ...
0
votes
1answer
21 views

Display all attached image of every post of custom post type and link to original post

I've written a loop that displays all the images that are attached to every single post of a specific post type. The post type is called "atls_events" and I'm outputting an image size called ...
0
votes
1answer
20 views

2 queries with counters

I have 2 loops on a page both containing a counter to implement slightly different code every 6 posts. For some reason though the second loop is implementing the different code sometimes after 4 items ...
0
votes
1answer
41 views

How to add add more properties to WP_Post object in search results loop

I am using a plugin called Event Organiser, and it seems that it will only append its custom properties to the post object for all other instances of the WordPress loop except the search. Is there a ...
0
votes
1answer
29 views

Why doesn't is_page(id) work in functions.php?

When is code in functions.php executed? Is it during the loop? The following does not work when placed in functions.php (not within a function) : if (is_page( 27 )) { echo 'this is the apply page'; ...
0
votes
0answers
11 views

How to add jQuery div element to each image on wp site?

I'm trying to add the "Share" button to each of the attachments inside of the post. I found function that allows to get all attachments on the post: ...
0
votes
3answers
36 views

How to get name of custom taxonomy

I need to get name of current custom taxonomy in archive.php file when page is showing posts belong to the one of custom taxonomy categories. It's easy do it in WP loop but I need get it in front of ...
0
votes
0answers
11 views

I'm trying to get post_author and post_content

I'm using foreach ($result as $row) and I can use: <?php echo $row->post_title;?> or <?php echo get_permalink($row->ID);?> and they work fine. But i cannot use : <?php ...
0
votes
1answer
19 views

Loop multiple taxonomy in custom post

I have a custom post called "rock" and taxonomy "genres" i need to filter the posts with tag or something like post_type > taxonomy > taxonomy_tag (tagsss) I can not find a solution :( i have ...
2
votes
1answer
129 views

If No Search Results, Show Posts from Alternate Search Query

I have a pretty standard loop which outputs "Sorry, No Posts Found" when a search result comes up empty. if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part ( ...
0
votes
1answer
28 views

Query all post types but limit to parents

I'm building a site with several post types and am using a single index.php to query the archive for each one in turn. One of these post types is hierarchical and I'd like to just query the parent. I ...
0
votes
0answers
28 views

$post breaking container loop

Problem I have a foreach loop grabbing posts inside an advanced custom fields repeater. When it's finished looping through posts it breaks the repeater. I believe the problem is with $post as far as ...
0
votes
0answers
23 views

Popular posts from 7 days loop

I'm trying to create a "loop" which will display Popular Post from a week or any other timeframe. What's the best way of doing it? Also, is it possible to order the posts by views? EDIT: Here is ...
0
votes
0answers
22 views

Search for posts with specific tag inside custom page template

I'm developing a Wordpress blog where there are two custom pages - i.e., different from index.php. In there, there are two albums of photos, with the photos listed on a div above. I've put an input ...
0
votes
0answers
17 views

Custom Loop and the_title();

I have used custom loop to process posts however, the loop cannot get the right title or the custom fields. I am using ACF plugin The weird thing is that the loop gets the right content through ...
1
vote
4answers
110 views

404 error PageNavi custom type taxonomy | wordpress

I have a custom post type called rock with a custom taxonomy called genero. taxonomy-genero-curiosity.php mypage/Rock/curiosity/ When i click subsequent paginated page links (e.g. [2], [3], ...
0
votes
1answer
37 views

How to do a loop inside a loop?

I'm trying to get posts from a custom posts using WP_Query. <ul> <?php $query1 = query_posts( array( 'posts_per_page' => -1, 'post_type' => array('specialties') )); ...
0
votes
0answers
25 views

index.php is only displaying current month's posts?

The blog portion of my WordPress site (a corporate website) utilizes index.php as the default blog page. However, while the page properly shows the PAGING for the other 40+ pages of blog posts, the ...
0
votes
0answers
18 views

First post separate from loop pagination count? [duplicate]

What seemed trivial at first has gotten me completely stumped. Here's what I have in my index.php and credit to this answer if ( is_home() && !is_paged()){ the_post(); ...
0
votes
0answers
15 views

Order main loop by category and then post_date

I'm creating an "announcement" post category. I'd like those posts (using the category id) to appear first in the main loop sorted by post_date desc and then the rest of the posts sorted by post_date ...
0
votes
1answer
25 views

While loop with an exception after a count is reached

I'm trying to edit the tag.php page so that it displays all tagged posts (as it normally does) 'but' I want to call a function after the 3rd post in the loop. Current Code <?php /* The loop */ ...
0
votes
0answers
23 views

How to add an if statement for one of the custom fields on the following loop?

I have a bunch of custom fields on one of my post types, that is displayed randomly but in a fixed order. The names of the custom fields are always the same, and for every loop there is an increasing ...
-2
votes
1answer
68 views

WooCommerce Only OnSale Products Loop Snippet [closed]

I am trying to pick only OnSale products in a WooCommerce loop through a snippet. For that I tried to use below code but this one is picking all products. I only want to pick OnSale products in loop. ...
4
votes
4answers
330 views

Why do themes rely on “The Loop”?

I've been looking at Wordpress themes development recently, and I'm trying to understand why Wordpress is coded with "The Loop", rather than providing an array of posts that you can loop through with ...
0
votes
1answer
28 views

pre_get_posts main_query not displaying after applying tax_query filters

Maybe someone can help me identify a problem I am experiencing with the pre_get_posts action. I have used the same code in another project before and it worked fine. I even went through line by line ...
0
votes
1answer
42 views

Load 3 posts in flexslider slide [closed]

I have a slider that i'd like to load 3 blog posts into each slide. I'm having a problem getting them all out correctly. I'm using Flexslider. The idea is to get 3 blog posts at a time into each ...
0
votes
0answers
58 views

Multiple Loops on category.php with pagination on last loop

I'm trying to achieve what should be fairly simple but I've hit a brick wall when trying to paginate the last of three loops on the category.php template. I've read just about everything I can find on ...
0
votes
0answers
23 views

Get posts by current taxonomy term child term

I am trying to create two different wordpress loops, each one will be using a custom taxonomy called 'walls'. Loop one: get posts by child term of the current pages term. Loop two: get posts by all ...
0
votes
1answer
35 views

Frontpage pagination by week

I'm trying to set up a frontpage with all the post from the current week. Well this was quiet "easy" (the query snippet): $query_string = array( 'post_type' => 'post', 'date_query' => ...
0
votes
1answer
77 views

Loop through multiple custom fields with increasing number

I have a problem with custom fields that I have been trying to figure out for a while, but with no luck. I have a section on the site I'm building that let's the users publish content form the the ...
0
votes
1answer
45 views

Get author meta data with no published posts in author.php?

Unfortunately the following codes only echo the spcefic default and custom author datas if the author has at least one published post :( <?php the_author_meta('description'); ?> <?php ...
0
votes
1answer
22 views

How wp maps urls into files

I am trying to understand how wordpress works. I have found this line of code in my theme: <?php echo get_permalink(get_option('Theme_search_page_id')) ?> If I get the that option from mysql ...
0
votes
1answer
24 views

Query pages by child term

I cannot seem to get this to work, I have tried everything I can think of and spent enough time googling, to get me to seek help elsewhere. I need to query pages in a loop, using the same taxonomy as ...
0
votes
1answer
15 views

How to query all custom posts of a certain type and checking what category they have

Here's what I have: Custom Post type: Vendors Vendor categories: Wedding Party Catering I want to query all Vendors and then assign them a class based on the category they are in. The class ...
0
votes
1answer
27 views

WP_Query for attachments without duplicating post_parent and displaying tagged image

I've tagged a number of media uploads on my site with the various products' names which are featured in them. The goal is to get a list of the posts which have been tagged with each product name, but ...