Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [loop]

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

0
votes
0answers
11 views

How do I add a loop to featured images?

I'm adding multiple images to featured images. And the theme I use is taking them as a preview. For example, I add 10 pictures. They are in turn playing just like a video preview. But he keeps going ...
0
votes
0answers
11 views

How to show No Post Found when a user has not posted anything yet

I am using Wordpress 5.0 By default, when a logged-in contributor click "Posts" or "All Posts", a list of his posts are shown. But when he has not posted anything yet, clicking "Posts" or "All Posts"...
2
votes
1answer
40 views

Show all posts in sidebar in single.php

Wordpress 4.x Why does the loop.php only show the current post in the sidebar when I view a post in single.php? I have: Post One Post Two Post Three If I view "Post One" (single.php), the sidebar ...
0
votes
1answer
15 views

Exclude category and post from loop in custom category.php

So I created a custom category.php where I have the following loop: <div id="category__product-grid" class="row"> <?php // The Loop while ( have_posts() ) : the_post(); ?> <div class=...
1
vote
2answers
125 views

If newest post of category is newest post in general, skip first post of category

currently I am working on some customized blog templating and was wondering if there is any way to find out if the newest post of a category is also the newest post of the whole blog, so I can skip ...
0
votes
0answers
16 views

Showing siteorigin widget on category page view

I am using the plugin Page Builder by SiteOrigin and I am modifying my category page to render a snippet of one of my custom widgets inside the single view. How would i render just a specific widget ...
0
votes
0answers
25 views

Wordpress Loop index Latest Post [closed]

I couldn't do the last things in the image. I want the last articles to appear in this area, but somehow I couldn't adjust it. I searched a lot Below are the codes of the last topics section. <!-...
0
votes
1answer
34 views

How to use `foreach()` in ajax call

I have written a code for retrieving data from the database using the ajax for WordPress. The following code is the one written in the functions.php. The code is for getting the id and names of ...
0
votes
1answer
22 views

WP Query - Posts Per Page not working in combination with category__in

I'm not sure whether it's a bug or i'm doing something wrong, but it doesn't seem like posts_per_page works at all when using category__in. My query is below, even though I've set posts_per_page to 1,...
0
votes
0answers
24 views

Second Loop Showing Only One Post on Single Post Page

The single.php page I am working on was able to display two loops successfully, the first being the actual page's post, and the second loop displaying the last 5 posts. However, since I have styled ...
0
votes
0answers
17 views

Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop

I'm aware there are already answers regarding this question (Insert html after certain amount of posts?). But I haven't managed to find a solutions to my specific problem. The post linked above rely's ...
0
votes
0answers
16 views

How to modify archive pages URLs to include dynamic prefix?

I am building a website in WP where content (news, announcements, events) are grouped by regions (e.g london, nyc, ...; these are custom post types). In all the contents, I have a meta box where I can ...
0
votes
0answers
9 views

Best Practice to display posts which contain a certain metadata

I'm working on a theme that allows the user to add meta data to a post. I want to display all the posts with my custom meta data on a front end page. However I am unsure the best way to go about ...
0
votes
1answer
18 views

WP_Query & Duplicate entries

I am currently using this code in order to get the latest three posts of my website, successfully and with no issues: $posts = get_posts( array( 'numberposts' => 3 ) ); but I want to switch to ...
0
votes
0answers
19 views

Split/group search results by post type?

So WordPress default search results/output page (search.php) searches for everything and displays everything. Pages and Posts together in my case. What I want is to spit these results. I tried it a ...
0
votes
0answers
26 views

My post loop needs to have 8 different post templates

Firstly let me just say I am a beginner with backend but have learned a lot the past few weeks working on this backend project my company has allowed me to work on. I've learned to use Ajax, create ...
-1
votes
0answers
13 views

How to use wp_query in different columns in single loop?

Solved I want use one wordpress loop display posts in a row as: <div class="row"> <div class="col-12 col-md-6"> post 1 </div> <div class="col-12 col-md-6">...
0
votes
1answer
25 views

inserting content of 1 Post to in another with a template hierarchy

I have a page template I use for landing pages for various ad campaigns. The template uses custom fields for things like headlines and other shorter pieces of content within the page. However the ...
0
votes
1answer
35 views

Multiple Custom Post Type in Taxonomy Archive Causing White Screen

So basically I'm trying to add multiple custom post type in my taxonomy archive. Here's my code: <?php $args_trip = array ( 'post_type' => 'trip' , '...
0
votes
1answer
11 views

Adding a Section for Visitors

I habe a basic dog care website where I would like to have a lost dog section where visitors can post about their lost dogs with pictures and custom fields like communication and location info. But ...
0
votes
0answers
31 views

query problem for display with pagination

I developed a wordpress page template (which is supposed to display digital products that I sell on my site) that worked without problems for months, but since yesterday, the page template doesn't ...
0
votes
3answers
34 views

Regarding a custom loop and output HTML tags

I want to make the code to display the list of the page title in footer. I made the following code in functions.php: add_action('yamada_action', 'list_page_2'); function list_page_2() { ...
3
votes
1answer
43 views

Why do I need to use The Loop on pages (inside page.php etc)?

This question is addition to the following question. The answers to the linked question say that you have to write THE LOOP inside each php template file, but what is still open is WHY? why is it ...
0
votes
1answer
25 views

ACF background-color per post in a WordPress loop

I have the following loop in WordPress: <div class="container"> <?php $news = array( 'post_type' => 'post', 'category_name' => 'angebote', 'order' =...
0
votes
0answers
10 views

Instant events in wordpress

I'm looking for a solution where I can have the blog page update automatically when a new post it's published without the page refresh. I could update the div every 10 seconds with content from ...
0
votes
0answers
29 views

Modify core files to display products by category

I'm pulling my hair over here searching and trying to modify the WooCommerce core files. So, what I am trying to do is modify my theme's woocommerce.php file because I want to display the products ...
0
votes
0answers
15 views

Latest post to style different and other post in loop

<div class="page blog-page-listing"> <div class="container"> <div class="page-title"> <h1>Recent Posts</h1> </div> <div ...
0
votes
1answer
32 views

display posts of custom post type with custom taxonomy

I have created a custom post type 'CPT_A' with CPT UI plugin. I have also created custom taxonomy 'Category_A' and 'Category_B' for 'CPT_A'. I have Posts 'Post_A', 'Post_B', 'Post_C', 'Post_D', '...
0
votes
1answer
15 views

Why is my loop not populating the page with my custom taxonomy terms from my custom post type?

Why is my loop not populating the page with my custom taxonomy terms from my custom post type? Currently it is displaying an empty box instead of pulling in the custom taxonomy terms from my custom ...
0
votes
0answers
29 views

Wordpress Query to show children of the current post using Elementor to design the page

I am trying to create a custom query to show the children of the current post. I am use the custom post type "services" and using Elementor as the theme builder. Elementor requires the query to be ...
-1
votes
1answer
23 views

how to handle multiple forloop?

I have and order_id as array but wc_get_order accepts only one id at a time how to loop through order_id and let the list of item id and item name? i am using this inside a class. it works fine if ...
0
votes
2answers
21 views

Show parent category and subcategory once in while loop

I have tried several things but unfortunately do not manage to do it in a good way. I use a while loop to pick up dealers (custom post type) from different countries and provinces. In this loop of ...
0
votes
1answer
31 views

List events by month

I am working on a WordPress site consisting of a custom post type called "events". Each "event" consists of a custom field called "event date". I'd like to organize all the "events" by months based on ...
0
votes
2answers
37 views

Last post in loop when even

I'm using this code to try and check the last post on each page loop is even so i can add different classes. This works to check if its the last post : ( ( 1 == $wp_query->current_post + 1 ) == $...
0
votes
2answers
27 views

Loop through posts? Want to remove extra newlines in actual post HTML/content on backend

I have a ton of posts that we created, but unfortunately there are a lot of blank spaces. This is an example of what I see on the backend, in the actual post: <h1>This is a post title</h1&...
2
votes
1answer
17 views

Last post is not showing up

I'm developing a custom template for a customer that wants in his website the possibility to filter posts by month. After creating an archive.php page and placing the widget "Archives" in my sidebar I ...
0
votes
0answers
11 views

Trying to get posts in a sub-subcategory of custom taxonomy

I have a custom taxonomy, which is structured like Cars --Ford --VW Trucks --Ford --Dodge And then I have posts in this post type such as "Beetle" and "Jetta" assigned to the "VW" subcategory and "...
1
vote
1answer
19 views

Why is my loop not dynamically grabbing the correct Category and displaying all categorized posts?

Objective: When a category is clicked I would like the category.php page to dynamically pull in all posts filed under that clicked category. Example: News -> (Action:Click) -> Category = News ...
1
vote
1answer
34 views

Custom get_the_excerpt() only works on first post

I use a custom get_the_excerpt function in my theme. It works perfectly for the first post in the loop, but the other posts are using the standard excerpt function. I do not understand why? The ...
0
votes
0answers
31 views

How can I get my pagination loop to display the correct number of total pages?

Currently my pagination is showing 7 posts on the first page and 6 on each page after. This is what I want. The current readout looks like this: . The total count of my pages changes as soon as I ...
0
votes
0answers
24 views

pagination for meta_post

I have some problem, I want to show my meta_post 2 per page (1 post have more than 1 meta_post), but my code still show all meta_post $metas = get_post_meta( $ids, 'value_gallery', false ); foreach (...
0
votes
1answer
22 views

How to pass current loop data into nested loop

I have a custom post type (activities) and on each post I loop through another custom post type (tours). In this second loop I want to create a variable containing the current post's name so I can ...
0
votes
0answers
14 views

make pagination on single-gallery with content from meta value

I have a file single-gallery and this content is image from meta_value , and i want make pagination for limit show image per page on all post , this my code $paged = (get_query_var('page')) ? ...
0
votes
1answer
17 views

How do I put my frontpage featured image in a page template for home.php?

Important: I want to makes sure this is clear: I am not asking how to get the post thumbnail. I am asking how to get the featured image for single page which is created through the Gutenberg editor ...
0
votes
2answers
31 views

List all posts associated under custom taxonomy

I have created a custom post type. Within that I have assigned two custom taxonomies. One (computer) is what I use to drive the template files and slug of page (taxonomy-computer.php). The second (faq-...
0
votes
2answers
49 views

The Loop not looping?

After much troubleshooting and searching, I think I finally understand how to get The Loop going. Except I can't seem to get it to actually loop! I have created a Child theme, and added a functions....
0
votes
0answers
21 views

How to display single post and the 3 previous posts on home and single

I am looking to have my site display a single blog post at a time, with the 3 previous posts displayed by thumbnail/title on the right. I was successful in getting this to work for the current post ...
0
votes
0answers
43 views

How do I use AJAX Query in my posts loop?

I have this function in my functions.php. All the AJAX and Query is working but displays the results of the loop right below the AJAX filter. I want the query loop to display in my main theme's ...
1
vote
1answer
26 views

What's the WP way to load remaining custom posts?

I am displaying custom post types, grouped under their custom taxonomies (basically used @ChipBennett's answer from here: Display all posts in a custom post type, grouped by a custom taxonomy) for a ...
0
votes
1answer
18 views

How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta

I hope I can explain this without being too confusing. I have a site where I have a custom post type that has two custom hierarchical taxonomies ( categories ) and each post also has a meta filed ...