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
0
votes
2answers
25 views

Orderby my needs in foreach loop like by title or something?

in a cpt i can check some values (checkboxes) in a metabox. i can access this values by $meta = get_post_meta(get_the_ID(), '_custom-meta-box', true ); after that, i do a foreach loop: foreach ($...
0
votes
0answers
12 views

how to write a function to show lists of running processes or while loop functions in php

Please i have a while loop function that am using to insert data into my database periodically, for some reasons i found out that while loop is more easy to use than cronjob, while loop runs without ...
0
votes
0answers
9 views

One post per one column item in a row. How to?

I am planing to construct a new responsive website from sratch. Initial plan is at least one row with three columns for index.php (within body tag). What approach would be better to achieve my goal so ...
-1
votes
0answers
35 views

Display ACF From Custom Post Type Taxonomy On Single Post

On my gaming website I have created a custom taxonomy named "game". Using ACF, I have created 2 color picker fields ("game_color_1" and "game_color_2") that allow me to customize the colors of each ...
0
votes
0answers
12 views

Display related posts based on matching the category and a tag within a custom taxonomy group

Hi community and thanks in advance. My aim, I simply want to display Pubs/Bars related by the same area tag, automatically, on every post. I found and followed what looked like an excellent solution ...
0
votes
2answers
17 views

Use ACF Category Image for all Taxonomy Archive Views

I’m wondering if you could help with some code I’m struggling with. I’ve got an ACF Image Field on the Post Category Taxonomy. I need to add it into the post loop so the category image shows up ...
0
votes
1answer
13 views

Content Visibility for Wordpress is not working (Drafts, public etc.)

I have an old WordPress installation. Unfortunately, public posts and drafts are displayed on the front. I think it's because of the wordpress loop. The following code is used: <section class="...
-1
votes
1answer
18 views

How to add custom HTML markup and classes to the_content()?

I have HTML template for output from the_content() function. It contains elements with custom classes such as <blockquote>, headings or paragraphs. <p class="mb-40">Nemo enim ipsam ...
0
votes
1answer
24 views

Solved - Inserting content inside the WordPress loop

I currently trying to insert a block of custom code inside the WordPress posts loop which is using JetPack's infinite scroll functionality. In theory, this should be quite simple but is proving ...
0
votes
0answers
21 views

Set ranking number orderby meta_key for specific Posts

I use a custom field totalreviews for rating my products I need to figure out how to get a rank listing like #1 OF 100Posts #25 OF 100Posts and display rank in single.php or homepage I did some ...
0
votes
1answer
57 views

Group posts in a category based on tags in custom taxonomy

I had my built-in posts set up with categories and tags. I created a template that would display posts of the category that matched the page slug. then it would group them by the Tags. for example, ...
0
votes
0answers
8 views

How to show related post with category DESC (ASC) IDs of ID current post

I have example Post 1(id-1), 2(id-2), 3(id-3), 4(id-4), 5(id-5), 6(id-6), 7(id-7), 8(id-8) ,9(id-9)... with same catergory. When in post 9, i need show related post 8, 7, 6 When in post 8, i ...
1
vote
1answer
27 views

Get single post from tags array

I have wordpress and many posts. Every post have on tag. Posts may have same tags. I have: post1 tag1 date1 post2 tag1 date2 post3 tag2 date3 post4 tag3 date4 post5 tag2 date5 I have get: post1 ...
0
votes
1answer
13 views

Wordpress posts in the loop not stacking side by side

I was following a wp theme developement tutorial but somehow the posts from main loop and projects are not showing side by side ..although all other css works fine here is my code front-page.php &...
0
votes
0answers
10 views

How do I match a current post category slug with a custom taxonomy term to display the custom post which is in that custom taxonomy term?

I currently have a custom loop which is placed in single.php, this gets a post from a custom post type called 'game' by tag and matches it to the tag of the current post, so if the current post has a ...
0
votes
2answers
58 views

wp_query is showing posts from other categories

I am trying to make a custom loop that will display the latest 5 posts from select categories, all using a single query. I want the loop to display the category name followed by the 5 posts, and then ...
1
vote
0answers
16 views

Orderby is working with one query but not with other

I'm using a shortcode to show some price boxes. I use a CPT with a custom field called 'posicion' which has a number that I use later to customize the loop. This is the code: <?php if ( ! defined( ...
0
votes
0answers
11 views

WooCommerce - list products AND subcategories together in a-z order. Possible?

in a website i am creating (not live yet) i have products in a main category. I also have subcategories that have other products in them. I know that WooCommerce can display subcategories and ...
1
vote
0answers
20 views

A smarter way to display multiple loops inside a page template

I'm trying to make a page with multiple loops. I need each loop to display posts from a particular category. One category after another. At the moment I have the loop below displaying posts from a ...
4
votes
1answer
59 views

How to exclude latest x posts from a paginated query?

I have a WordPress loop, that is part of an AJAX call. Every time a button is clicked, this function is called, runs the below loop and outputs the next 6 posts. There are already five posts shown by ...
1
vote
1answer
21 views

Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files

I have two loops that display posts: the 'default' loop (in home.php), which displays five posts. At the bottom of the page I have a button, that invokes an AJAX call, which calls a second loop and ...
0
votes
1answer
14 views

How to unlink all posts from tracking same amount of views

I'm trying to show the top 5 most popular ( most viewed ) blogs. It is working as it should and then I added a script in the functions.php to display the views just while I build this so I can see it'...
0
votes
0answers
14 views

Single WP Query that Displays Category Name and Posts in that Category

I am trying to create a WP Query that I will put into a shortcode to be displayed on a page. I only want the newest 5 posts to show up for each category. Additionally, for performance, I want to ...
1
vote
0answers
22 views

Fetch Children of Grouped Products Inside WooCommerce Product Loop

I am overriding the WooCommerce archive-product.php in a child theme so I can list single products and grouped products. The loop outputs each product as a single item which is what I want for Simple ...
0
votes
0answers
39 views

Can't add new plugin or themes on a wordpress multisite network from the primary site as administrator. Error: ERR_TOO_MANY_REDIRECTS

I can't add new plugins or themes on a wordpress multisite network from the primary site as super administrator. It shows this error: ERR_TOO_MANY_REDIRECTS. However, I am able to access all pages, ...
0
votes
0answers
13 views

how to get count of first if statment result row

I have loop and inside this loop 3 condidtion ,, foreach( $posts as $post ): $post_id = get_the_ID(); $upload_active = get_the_author_meta( 'upload_active'.$post_id.'', $uid ); if ($upload_active == ...
0
votes
0answers
13 views

Multiple Loops In Tabs Only Displaying First Loop

I've browsed all the other questions that could be related to this and still can't find the answer. My code is only displaying the results of the loop in the first tab, but won't show it in the second ...
0
votes
0answers
13 views

Infinite loop when nesting have_posts()

I need to create blocks of posts in my theme. So far, I only thought of one possible implementation - a nested loop: The Code for ($i = 0; have_posts(); $i++) { for ($j = 0; have_posts() &&...
0
votes
1answer
92 views

get understrap pagination to work with custom query

I am using the excellent understrap Wordpress boiler plate theme. It has a pagination function that works if you put inside a standard loop like so: <?php if ( have_posts() ) : ?> <?php ...
0
votes
1answer
39 views

Wordpress posts loop not displaying all posts on blog

I'm a beginner developer so I'm sorry if I've made some obvious mistake, but I simply don't get why my loop for posts is not displaying all of my posts, I created 14 test posts and set the Reading ...
1
vote
0answers
13 views

Create a new query in function.php to filter blog posts

My goal is to filter blog posts (those which are requested in the blog page - Reading settings) depending on an expiration date, and then to change their category depending on a choosen future ...
1
vote
1answer
41 views

How to vary post loop results layout and resume?

When I am outputting a post loop in a particular mark-up, how do I break at certain intervals, use a different mark-up for a number of next posts and then resume the loop at the appropriate point in ...
0
votes
1answer
15 views

Check the stored / cached WP_Query with transients on post change

right now I have WP_Query stored for 24h (1day) with set_transient function. Everything works fine like it should. But if for example I change the post which is in the stored array to private or ...
1
vote
1answer
15 views

problems with loading posts in a table-row

I am trying to modify a code in a webpage. Currently the page has a table, table-row, table-cell structure where thumbnails which represents posts of a specific category and associated data are loaded ...
0
votes
1answer
29 views

Foreach Loop Of Post Types With Nested If Else If Not Completing Process

When my plugin is updated I am trying to write new values to the database. I am running through the post types and if it is Page Product or Post I want to place INDEX in to the DB. Else I want to ...
1
vote
0answers
21 views

Separeting product from post in search result

I am trying to separete products from posts in the search result. I can see the loop there search in both. if( have_posts() ) { while( have_posts() ) { ...
0
votes
0answers
22 views

New template file does not load category-specific post

I have 2 Files: index.php newStuff.php I want to get all posts with one specific category with this Code: $args = array( 'posts_per_page' => 1000000000, 'cat' => '', 'paged' => ...
0
votes
1answer
32 views

Hiding a row in the loop if empty

I'm trying to hide posts that have a certain category, but when a post is hidden, it's displaying and empty row. I've tried to move around my conditional statements but it just breaks my logic or page ...
0
votes
0answers
33 views

Show a message if there are no active posts in category

I want to show a specific message or a page or post if there are no active posts in a particular category. Currently, it shows a default "Content not found" message. I created a new template-blog.php ...
0
votes
1answer
52 views

Daily drip of posts - based on user 'startData' - ordered oldest to newest

I would like to "Drip" lessons for my class - 1 a day. In the index for the lessons, on the first day, you would see the first lesson, and then on the second day, the second and first lesson, etc. - ...
1
vote
1answer
36 views

Displaying multiple loops based off of category

How do I get this loop to detect a specific category, and change the html if it's a different category. In other words, if a the category is detected, I want to style the blogs with the specific ...
0
votes
0answers
68 views

Show custom post type event if current day using ACF

The following code pulls events from a custom post type that used Advanced Custom Fields, that is shown on an event listing page. It shows upcoming events as desired except when the event is on the ...
1
vote
1answer
66 views

Multiple taxonomy And acf filter group by

I have a widget that must display my custom post type. I don't display title or content, but just the values of 3 custom fields (acf) : start date, end date and city. Here is my loop. I grab all the ...
0
votes
0answers
13 views

Retrive and display first numbers seperated by commas in post content

function find_the_number() { global $post, $posts; $first_number = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/^[0-9,]+$/', $post->post_content, $matches); $first_img = $...
0
votes
2answers
28 views

Display all the terms within a custom taxonomy

I am looking to make a few different displays on the home page of terms within certain taxonomies as well as their image field as defined by ACF. I have been looking online and found 2 main different ...
0
votes
0answers
23 views

get_page_by_title not working inside fucntions.php

so here is the deal I have episodes custom post type this post type needs the id of the series to get some data like image and description etc... Now I am using a plugin to add posts to the site and ...
0
votes
0answers
20 views

Looping through dummy posts and showing them in the main index.php

I'm following a course in WP, fairly new to php but i have some experience with javascript, bootstrap css and html. Currently I'm trying to loop through all the dummy posts that I imported as XML file ...
0
votes
0answers
18 views

Show custom content when loop or wp query reaches specific time?

Like Facebook, the birthday of a user will showing something like “month year day, you were born” on his timeline, or on someday it will show “graduated form ?? School”. Is it possible for Wordpress ...
-1
votes
1answer
30 views

Pagination in category.php not functioning

Original Url: https://www.something.com/category/ftm-atf/ When I add pagination in, the following url is generated which results in a 404: Paginated Url: https://www.something.com/category/ftm-atf/...
0
votes
1answer
26 views

Current post categories and subcatecories outside of the loop

What I would like to achieve is getting the posts categories and subcategories (without needing subcategories to be related to this post) (when viewing the post) in a list outside of the loop, ...

1
2 3 4 5
62