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.

Filter by
Sorted by
Tagged with
1
vote
1answer
11 views

Can't get custom posts of taxonomy to show

I have a custom post type called 'brand', with a taxonomy of 'brand-categories'. try as I might, I cannot find a way to display a list of posts in the current taxonomy. can anyone help? <?php ...
0
votes
0answers
24 views

BLOG LOOPS Not WORKING CORRECTLY -

I am having issues with my blog loops. I had someone customize by site but they made a mistake with the blog posts. ISSUE: I have three different pages that feature blog categories (events, news, ...
0
votes
1answer
19 views

Custom Post Type has wrong label and is not found when called by a loop

I'm new to WordPress (and to code), having just started my classes. I am working on a project with a few students and can't find a way to call my Custom Post Type. I tried several solutions from ...
0
votes
2answers
16 views

How do you output an unknown number of images in a custom post type with desired markup?

I'm working on a theme that will have an image gallery within a custom post type. I'm able to insert them into the post (using Advanced Custom Fields and embedding them in a WYSIWYG box) but I was ...
0
votes
0answers
42 views

Submit form for loop of products of the term with AJAX

I am developing a group shopping cart that allows group user to order from the group page. I have a product term page where user can buy all products at one time. In fact, they must have to buy all ...
0
votes
1answer
13 views

How to show specify category template for both parent and child category

I tried to create a category template apply for parent and child specify category. I has create a file name 'category-1.php , in this file I used the loop for get the list of post: <?php if (...
0
votes
2answers
15 views

How to get current page id and compare it to looped pages inside the same page?

I have a page template named overview.php which inside shows all the pages that are of the same category. As a result all the pages with the same category are printed but so is the current main page,...
1
vote
1answer
13 views

Get a list of posts with associated meta_value

Recently I began to use the Custom Fields. I would like to display a listing of posts which contains the meta_key "oldtimer" and also get the corresponding meta_value. Here is the expected result: &...
0
votes
1answer
26 views

Change front-page layout after x amount of posts ( while in the same loop)

I'm trying to change the layout of my front-page after x amount of posts, then returning to the original layout as shown in the image below. <?php $paged = ( get_query_var( 'paged' ) ) ? ...
0
votes
1answer
17 views

Some posts not displaying by taxonomy term

I've run into something very odd that I don't think I've ever seen before. I'm trying to query a custom-post-type and organize the results into groups by a custom taxonomy term. The post is Project ...
0
votes
0answers
18 views

how to select posts in the loop published before x date?

I'm trying to select posts in the loop published before O4/2007 so I can target an html element, I had a way of doing this through a varblock in movable type - I'm kind of imagining this is pretty ...
0
votes
0answers
15 views

Can´t update BDD in time

Mi expertise with WP coding is basic, almost reach intermediate level. I know there must be a way to achieve this. I am using 2 loops one inside the other, to find matching values and save in DB. ...
0
votes
1answer
36 views

ACF Repeater loops and resets - where is the reset_rows() documentation? [closed]

I love ACF, its great for developers and it seems to have so much support. BUT... Why is reset_rows() not in the documentation? I created a function that can delete repeater rows at different times in ...
0
votes
0answers
12 views

Function to DRY up several ACF relational loops

Like the title says, I am using ACF to display data from 3 relational fields. The problem is that I have to repeat the loop 3 times, one for each of the lists I want to render, I feel like there has ...
0
votes
1answer
22 views

“read more” redirects to the wrong page

I would appreciate it if someone can help me out. I am having issues with my blog posts. I had someone customize by site but they made a mistake with the blog posts. I am no longer working with them. ...
0
votes
0answers
16 views

Diffrent layout for posts [duplicate]

I have two rows to display posts in first row i have two posts image + content , image + content And in second row the post layout change means content + image , content + image can you solve this my ...
0
votes
0answers
14 views

Listing only matched result line if specific tag and category is matched

For my Campus Project, I am developing a Travel based website where Touring Spots will be achieved and nearby Hospital, Shopping Mall and Hotel names will be listed on the following touring spots post....
0
votes
2answers
30 views

Get data from PHP to JavaScript to set position of each post on front page

I've created a custom post type called project for my Wordpress theme, which works fine. Each project has several custom fields, including a set of x and y values that indicate where the project ...
0
votes
1answer
22 views

Display current post position in Elementor Posts widget

I'm using Elementor 2.6.8 + Elementor Pro 2.6.2 I'm designing an Archive template to display a list of Custom Post Types filtered by custom taxonomy terms. I'm using Posts Widget from Elementor Pro ...
0
votes
1answer
38 views

Why my loop isn't working? [closed]

I am using this loop and instead of getting my posts(blogs) i am getting pagetitle in my case Home and Homepage content <?php while(have_posts()) { the_post(); ?> <h2><?php ...
0
votes
1answer
46 views

How can I group posts by months and years?

I have posts under a custom post type which I like to display in a page grouped by Year and Month. In the page template that I create, I managed to separate them by month, but still without grouping ...
0
votes
0answers
19 views

Woocommerce - show all product variations on shop and category

I found the code below to display variable products in the shop. After a small modification it works fine. But it also displays the variations in all categories, instead of only showing the variations ...
0
votes
0answers
17 views

How to show post views shortcode data for each post on Posts List Page?

Example: [shortcode id=""]. I just want to how to dynamically fetch each post ID on Posts Lists page over archive page or normal posts page inside the shortcode placed in excerpt. Currently I'm using ...
0
votes
1answer
21 views

Multiple loops on same category with different design

I am having a problem regarding the showing the multiple loops on the category posts i want a posts from a category=social where 3 design is located the structure is as follows Note: I want a ...
0
votes
0answers
15 views

Nested tax query arguments returning function is returning wrong arguments

I'm outputting the skus of products that satisfy my tax query condition where multiple tax queries are nested by "AND". here is my code $args = my_brands_loop(['brand_name'=>'mytag','shapes'=>...
0
votes
0answers
16 views

Need to display a Jan 1st post as the site's front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc

slightly unusual client request. I'm using Divi and I have a nice Divi layout created for a video and text post which is ready to go. The client wants to create 365 posts (one for each day of the year ...
0
votes
1answer
27 views

Wordpress posts loop pagination - first page return 125 posts instead of 10 and the rest return 10

I'm trying to show 10 posts per page with pagination on WordPress and the first page return 125 posts instead of 10 and the rest of the pages return 10 posts as requested, please assist :) $paged = (...
0
votes
0answers
40 views

Pagination inside the blog page not working

I have a widget which creates a grid with pagination. If I am using the pagination then it works fine when used on the page to display grid. But when I am using that in inside a blog post. The ...
0
votes
1answer
20 views

Only Show Excerpt After First 3 Posts

I'm using the template part below and would like to only show the excerpt after the first 3 posts. The first 3 posts are formatted differently as "header" posts and thus I'd rather not have an excerpt ...
0
votes
2answers
34 views

Loop is crazy - one row displays wrong count of posts [closed]

Im having a loop with count to add a clear after 4 items. It is working pretty well but theres one rebell row that will only take 1 post. Code: <section class="bonds-funding"> ...
0
votes
0answers
16 views

Why do my custom post type show up in all pages?

I was doing a page with template-parts to call my custom post type but the posts are popping up across the top of the site, I think it's because of the query , when I deleted it they stop popping up ...
0
votes
1answer
24 views

Yoast taking over my Wordpress title tag [closed]

I have this code: <h1><?php the_title(); ?></h1> That is meant to display the title of my blog post only. But because Yoast has a SEO title of something else, it is displaying ...
0
votes
1answer
9 views

Latest posts feed with a specific post always first

I have a latest posts slider working nicely. I would like to push a specific post (ID 123) to always appear first. I believe I could run multiple queries but every attempt has failed. I'm running out ...
0
votes
2answers
37 views

loop in single.php of the same category

How can I put a loop in my single.php that shows the posts of the current category of the single and following the code structure that I have? The question comes, because I can not find the correct ...
0
votes
3answers
18 views

Get custom taxonomy value of post and output posts in same taxonomy

I'm trying to show related videos on my single post template. I've set up a custom taxonomy called 'sub-category' in Posts. I want to get the sub-category of the current post and loop through any ...
0
votes
1answer
20 views

How to create an IF statement in the Main Loop for Custom Post Types

Firstly, this is my first WP project and I'm learning as I go... I know this is probably an easy thing to achieve, but for some reason I'm having trouble getting it to work... so apologies if this is ...
0
votes
1answer
23 views

Loop through ACF taxonomies and output associated posts

I have a page template that loops through all existing post categories and outputs 5 associated posts for each category. I want to change this so it only outputs the categories I have selected in an ...
0
votes
0answers
9 views

How to use a foreach loop to create a dynamic post by fatching pods page

I have got the result in PHP but facing issue in WordPress with pods to create the following dynamic post <?php // an array to fetch pods page $num =array("10"=>54, "9"...
0
votes
1answer
23 views

Pagination Error : Duplicate argument being outputted

I've been writing a custom search.php loop for some time now and I'm running into a weird problem. My php argument is outputting some unexpected results by repeating the template file. Currently I ...
0
votes
0answers
18 views

Store CPT 'Reviews' average ratings to a WordPress DB table or to a DB custom table?

I am working on this portal in which users can review the services (with description and rating) of a cultural place. BASICALLY, I created two Custom Post Types (CPT) with Pods, one is ...
0
votes
0answers
15 views

How to show text near a specific word/tag/category?

can someone give some examples of code that I can use in the tag and category loop pages, which will give out the content near a word? Here is an explanation. The default function of the category and ...
0
votes
1answer
85 views

Exclude a Woocommerce product from WP_Query

I'm using a WP_Query for get products from categories, $default = array( 'post_type' => 'product', 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish'...
0
votes
0answers
38 views

Loop is breaking my theme. How can I fix?

When my theme tries to load home.php, archive.php or any page that uses the loop, the page will stop loading exactly at the point the loop should begin, even the wpadmin bar won't load. If I navigate ...
0
votes
2answers
22 views

Previous and Next links not populating, have I missed something?

I'm working on a very simple theme. I have tried adding next and previous links and cannot get them to work. After trying a few different things, I ended up with this index.php (mostly based on ...
0
votes
1answer
31 views

Combine multiple separate lists into one

I have a custom query for my taxonomy of: $terms = get_terms( array( 'taxonomy' => "issueCompanion", 'hide_empty' => false, 'fields'=>'all' ...
0
votes
2answers
39 views

Add all category as classes in foreach loop

I am trying to modify a portfolio plugin with filter function. The current code for listing to post items is: <?php class FullwidthPortfolioGallery extends ET_Builder_Module { public $slug ...
0
votes
0answers
24 views

Custom meta fields not showing up in WP_Response Object via custom endpoint

I created my own Custom Post Type called person and a corresponding end route. I can modify my posts with the endpoint, using functions as wp_update_post,wp_insert_post and get_posts. I am facing a ...
0
votes
1answer
14 views

Pull in taxonomy field of custom post type in new query

I have a Custom Post Type named companion. Via Companion I create articles which are then associated with my custom taxonomy issueCompanion. Imagine issueCompanion as a publication which is released ...
0
votes
1answer
36 views

How to use alternate post layout at key points in post loop?

How can I intervene in my post loop output to show 3 posts in alternate mark-up, and then resume? I have a post loop that calls my post card template fragment, card-pair_top.php, to display like this....
0
votes
1answer
44 views

WP ForLoop to compare meta information of posts to determine what post to display

The short of what I am trying to do here is: I want to display only one post based on a date stored in a custom field. I only want to display the post if it meets two conditions 1: The date needs to ...