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
9 views

How to show ACF featured image for categories? [on hold]

I have a base-structure of a category loop, only for categories, no articles or sites. Now i want to show the featured image, but it is still not on the site. What am doing wrong? Output:
0
votes
0answers
21 views

Staggering featured post using 'sticky'

So I have Custom post type that occasionally will have posts marked as 'featured' Client would like to use the 'sticky' feature of WordPress to pick which posts from the CPT are classed as featured ...
1
vote
2answers
15 views

How to loop only categories without posts (+ show category featured image with acf)

I want to create on my blog a category loop with the featured image. But i don't know how i do that technical. You should only see a list of categories and click on them to get the category site. It'...
0
votes
0answers
15 views

How to create a category loop on my blog (ACF Plugin)

I want to create a category loop on my blog site, i already created some categories and uploaded featured images for them, but what's the next step? Thank you :)
0
votes
2answers
13 views

WordPress Image Slider Looping Title Not Working

In my index page there are two slider one is working fine but the second one is giving some problems. FIRST ONE <?php global $post; $i=0; $args = array('post_per_page' => -1, 'post_type' =>...
1
vote
1answer
9 views

How do I go about looping through a advanced custom field on a particular page inside of another page

I have one page lets call it page-home.php and I also have a page called page-custom-field.php I want to have a section of the first page where it loops through page-custom-field.php page and display ...
1
vote
2answers
26 views

Show post number in widget loop

It works in the category.php loop <article> <p>post-<?php echo $wp_query->current_post +1; ?></p> </article> <article> <p>post-<?php echo $wp_query-&...
0
votes
1answer
52 views

i can't receive data sent by ajax

First please excuse my English. So I built my own WordPress theme and want to use ajax in it, I'm using ajax for change post category in my post loop inside functions.php, so when a person clicked the ...
0
votes
1answer
17 views

Please tell how to stop the category from showing up on posts

Please tell me how to remove the category hence, it does not show up on posts. my content.php file is given below...which contains the code for showing up meta. but I am not able to figure out the ...
0
votes
1answer
15 views

Group search results by post type, but hide post types with no results

I was looking for a clean way to group my search results by posttype. I currently have 3 post types: Page, Post and Glossary. After a long search this answer in this thread got me what I needed. The ...
0
votes
2answers
32 views

Hide a category/posts from the homepage in wp

I tried it all and since i am not so good in this coding, I want to hide a category and his posts from the homepage I tried all plugins especially wp hide post but it needs pro version and seems ...
0
votes
0answers
16 views

Adding PHP to an if else loop

I want to run some PHP to show custom fields in a page; <?php $showExcerpt = get_theme_mod( 'auto_excerpt' , '' ); if( is_single() ) { the_content(); } else { if ( $post->...
0
votes
0answers
14 views

Accordion headings cuts off to second line on collapsing a accordion heading (used acf repeater)

<div class="container"> <?php if( have_rows('director_information') ): ?> <div id="accordion" role="tablist"> <div class="row"> <...
-1
votes
0answers
13 views

Pagination not returning all posts

I wonder if I could request a little bit of help; I am currently developing my first theme to learn more about the WordPress core, the majority of which is working fine however I seem to have a ...
0
votes
1answer
30 views

Repost post on specific date every year

I am creating a website about 'This Day in History' where I show daily events etc. all based on a particular date. Each post has to be re-posted every year, and a specific date so that everyday users ...
1
vote
1answer
22 views

Custom post type, organized by categories

I know there are lots of questions and answers out there for this very thing, but I'm having a hard time putting it all together. The goal is to get a <ul> with category names as the <li>, ...
0
votes
0answers
15 views

How to show the last article in a different way in my blog?

I am working on a blog area in wordpress (a theme of my own) and I would like to highlight an article or show the most recent article in a different way. What function should I call? Could someone ...
0
votes
1answer
13 views

WordPress Recent Posts - Loop

I would greatly appreciate some help, I have written a loop inside a list item however I'm looking to set a width and height on the thumbnail and display some expert "text" but limit the length of it.....
0
votes
0answers
22 views

Genesis custom loop for archive page

I know this question has been answered before but for the life of me, I can't find it anymore. I created a few custom post types and custom fields using ACF, now I know how to display the info in my ...
0
votes
0answers
10 views

next_post_link() and previous_post_link() in single-cpt.php file not working

I am trying to display links to previous post and next post in for a custom post type regardless of whatever custom taxonomies they are attached to. I have a custom post type called experiencecont ...
0
votes
0answers
18 views

woocommerce_wp_select options for user list

Here is my code for users select option in woocommerce backend. I can not reach dynamic user list in option array. function woo_add_custom_general_fields() { echo '<div class="options_group"&...
1
vote
1answer
16 views

Creating select dropdown with parent-level custom post types

I'm trying to create a dropdown with an option for each top-level parent. I've gotten the query down because when I print the results, I see the posts I'm looking for. My code is also creating the ...
1
vote
1answer
23 views

How do I display a list of posts under all hierarchical children of the current taxonomy?

Assume the following custom taxonomy structure: USA California Los Angeles San Francisco Oakland New York New York Buffalo Rochester Note: It's just sample data, so don't bother to correct it! ...
0
votes
1answer
30 views

Pagination on custom post type on front-page.php

I've seen several (and have tried at least 15+ methods here on StackExchange) ways of how to do the custom post type loop, none work in my case. I have tried methods using paged and without, using ...
0
votes
0answers
18 views

Remove product category placeholder image (Woocomerce)

I'm trying to get rid of placeholder product category images on the shop page. Right now I'm using this code to add a .no-image class to products that don't have an image so I can style them ...
0
votes
0answers
18 views

Create custom design for posts loop with pagination

I need to create a simple posts loop to be shown on the homepage (Meaning - I am in "page" and not "blog" or "archive" This is what I need: Display maximum of 5 posts there will be arrows on both ...
0
votes
0answers
12 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
50 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
16 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
133 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
17 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
1answer
53 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
26 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
25 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
19 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
18 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
10 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
28 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
28 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 ...
0
votes
1answer
26 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
38 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
38 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
46 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
30 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
1answer
40 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
40 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 ...