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
19 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
19 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
15 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
19 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
39 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
7 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
32 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
10 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
126 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
25 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
27 views

archive.php not showing the last post queried [closed]

I have this rare issue. When I visit archive page for a category, it shows all posts but not the last one. If there is only one post in the category, it does not shows any entry. I tried with the ...
0
votes
0answers
21 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 ...
-1
votes
0answers
31 views

Snippet to show lowest price in shop page for WooCommerce [closed]

I've set up a shop page on woocommmerce, its displaying all the categories available to choose from. However I can seem to find any threads on how to loop in the the pricing onto the page. I ...
0
votes
0answers
18 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
16 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
98 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
35 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
24 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
17 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
14 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
22 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
61 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
326 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
27 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
40 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
52 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
19 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
34 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
73 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
42 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
20 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 ...
-1
votes
1answer
32 views

Custom Post Type Loop inside Array [closed]

I current have a custom post type loop: $args = array( 'post_type' => 'locations', 'posts_per_page' => 10 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : ...
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
25 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 ...
0
votes
1answer
29 views

Add something after all sticky posts in The Loop

Let's say I've got some posts and some of them are sticky. The sticky posts are displayed at the very top in The Loop. while( have_posts() ) { the_post(); get_template_part(); } How can I add ...
0
votes
1answer
58 views

Select data from database and list it in Loop (Wordpress)

your Answear helped me but i stuck again. here is what i have done now : <?PHP define( 'WP_USE_THEMES', false ); get_header(); global $wpdb; $sql = "SELECT vehicle_id, manufacturer, series, ...
0
votes
1answer
31 views

Different number of posts showing in development vs production server

So I'm working on a website for a client. Everything works fine except for the fact that the number of posts showing in the homepage of my development server is different from the number of posts ...
0
votes
0answers
28 views

How to generate custom loop indexes

Besides the regular taxonomies, such as category, tag, author, archive, I also have some special indexes to display, such as list of all sticky posts, simple chronological index of all posts, top ...
0
votes
1answer
44 views

Scrolling Posts with Ajax

This is a very common question all over google , but there is a conflict between the ways we can handle this. I use this tutorial ...
0
votes
0answers
44 views

Help paginating custom loop

i'm trying to add some sort of "load more" button every X posts in this loop: <?php if(is_home()) : ?> <section class="pages clearfix"> <div ...
0
votes
0answers
26 views

Multi WP Query Problem [closed]

im using seprate multi wp query loop but first query cant return my values . anyone can help me ? $first_product = $_GET['first-product']; global $post,$wp_query; ...
0
votes
1answer
18 views

Issue with WP_Query (need a array of selected ID's)

Today I have <?php $loop = new WP_Query( array( 'post_type' => 'inspirations', 'posts_per_page' => 50 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> ...
1
vote
1answer
44 views

How to return only one instance of each, from the entire loop

I´m adding a filter function in a taxonomy archive template. The intention is to add URLs for filtering in a sidebar, and i want it to return a set of ACFs like zipcode etc... (postnr in this example ...
0
votes
1answer
26 views

Accessing Post ID Within Loop

I have a page called Products with an ID of '8' Within that, I have the following template part <?php get_template_part('loop', 'feed-products' ); ?> Then within that file, I have this ...
0
votes
1answer
55 views

Sort posts by first letter in the title not by first number

down vote favorite I have a custom post type that's used to display properties on a client website. I am sorting the posts by the title but want to ignore any numbers included in that title. so to ...