Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
22 views

When a foreach loop is used multiple times in blocks, is there a way to ensure a variable always has a unique value?

I'm a bit new to this so sorry if my explanations are a bit daft. We use custom gutenberg blocks on our site. One of them is a FAQ block where you can add questions/answers and they display as an ...
Andrew Shlaimon's user avatar
0 votes
1 answer
15 views

How could I prevent using the same custom loop in a template file when I only need to change one meta_query parameter?

I am displaying a set of upcoming fixtures for two cricket teams on the same page. The fixtures are created from a CPT and the relevant team is selected from a custom field. I have everything working ...
Craig Watson's user avatar
0 votes
1 answer
18 views

Custom theme on multisite has issues with standard loop output

I am experiencing the following error output when using the standard loop on page.php and single.php on a multisite-based WordPress installation. The loops are the same for both template types, with ...
Mike Hermary's user avatar
0 votes
1 answer
31 views

How to get the post title inside a custom block in a loop? block.js

I have created a custom post type and I want to create blocks that display its values. To start with, I created a placeholder that gets replaced with the correct values using PHP. Everything works as ...
Ghiath Sardast's user avatar
0 votes
2 answers
719 views

fetch from an external api call and display results in page

I have placed my external api call inside the functions.php file in the server and I created a shortcode for the api call. I'm familiar with React and I was expecting Wordpress to be somewhat similar. ...
bart lu's user avatar
1 vote
0 answers
11 views

Add More Featured Data Not Sending to Database

I have made one form which is two step based. also i have added feature add more. So when you add click show same filed duplicate on step two. Problem---- When i'm trying to send data by (add more) ...
Atiq Rev's user avatar
0 votes
1 answer
61 views

How to show correct td of table tags in wp_query loop

I Have this loop: <?php $post_ids_fetched = array(347, 258); $editor = new WP_Query( array( 'posts_per_page'=>4, 'post_type'=> 'earth', 'post__in' =&...
och's user avatar
  • 39
0 votes
1 answer
224 views

How do I display WooCommerce products in my query to rows of 3?

I have created a WooCommerce search plugin. It fetches products, however it only displays the products as one per row. How can I amend my query to display 3 products per row? Here is the function: ...
SavPhill's user avatar
  • 118
0 votes
1 answer
26 views

How to get posts by a certain author in inner loop using outer loop variable or post title WordPress

I am working on a WordPress site with staff bio pages. At the bottom of the page, I would like to include their most recent blog posts (if they have any). I have an outer loop that pulls the fields ...
Allyson Smith's user avatar
0 votes
1 answer
218 views

Saving meta box data from selected option's value in database is not working

I have added a organizer input filed using "select and option" tag, screenshot - https://prnt.sc/DtiJr5W178_g Here is my full code - // Callback function for Metabox <?php function ...
Md Maniruzzaman Moon's user avatar
1 vote
2 answers
264 views

How to use a conditional statement in a post loop but not count towards the "posts_per_page" if false

I have a WP_Query which has the "posts_per_page" parameter set to 12. I am then using a while loop to iterate over all of the posts and an IF statement to check whether a condition is true ...
Sam's user avatar
  • 11
0 votes
1 answer
258 views

Count the number of matching post names in foreach loop

I have a simple foreach loop that outputs an ordered list from a CPT 'post_subscribers' and an associated meta key called 'project'. $theposts = get_posts( array( 'post_type' => '...
dekkyd's user avatar
  • 7
0 votes
1 answer
40 views

How do I exclude the current post from the upcoming post query

Summary: I have a page template with 3 queries. Current Exhibition Upcoming Exhibition Past Exhibition The dates are custom fields. The problem I'm having is, how do I dynamically exclude the ...
Chris Brennan's user avatar
0 votes
2 answers
475 views

I want to show image from custom field image on my custom page template

I have created a taxonomy and in that taxonomy i have created custom field for image. Now I want to show that custom field image on my custom page template with category name. I have tried much it is ...
Abdul Rasheed's user avatar
1 vote
1 answer
410 views

Wp Query : Order by distance lat,lon

I'm new to this forum, sorry in advance :) I have a problem with my display of my posts Let me explain ^^ I want to perform an orderby => '$distance' and display the posts accordingly. $lat2 and $...
codenametest's user avatar
0 votes
0 answers
14 views

CPT loop doesn't seem to account for post date?

I have some custom post types called "products", all with different published dates. Below is my loop that grabs these posts: $args = array( 'post_type' => 'product', '...
mickdeez's user avatar
  • 101
0 votes
0 answers
401 views

How do I get pagination for get_posts() in WordPress or do I have to rewrite the whole code?

I inhertited a WordPress page with a long post list on one page that uses get_posts(). I need it to have pagination to not load all the posts (images, content) at once. Would I have to rewrite ...
Lisa's user avatar
  • 13
0 votes
1 answer
1k views

get_the_ID() in the footer returns wrong value

I'm using get_the_ID() in footer.php but it returns a wrong value. It might come from any of the plugin which is altering The Loop without resetting it after with wp_reset_postdata() as mentioned in $...
Basj's user avatar
  • 85
0 votes
0 answers
115 views

Give ID to divs inside the loop

I'm trying to make this code work on my WordPress site: https://codepen.io/eksch/pen/xwdOeK It is a simple code so that each menu item receives the active class when the user scrolls through the page, ...
Eduardo Reis's user avatar
0 votes
1 answer
38 views

How to get the last category name of a child category?

there. I've tried tons of solutions I've found in this forum before asking this. It's kind of hard for me to understand the php sintaxe. I have no idea how to do this and i've been stuck for days ...
Jay's user avatar
  • 11
0 votes
1 answer
366 views

Pagination contents not changing in Front page WordPress

This question has asked many time before and none has answers my question. I went through most of the answers before post this. I have a pagination query in home page. Pagination is showing and I can ...
user2584538's user avatar
1 vote
0 answers
30 views

Custom Tag Description unable to display just below and outside of the Loop

Hello StackExchange Team! In my wordpress tags for custom post type, the code <?php echo term_description();?> or outputs fine just outside and above the loop. The problem I am having is that ...
Okara Nnamdi Benedict's user avatar
0 votes
1 answer
40 views

Custom post type loops with different page templates

My website has two different page templates. Each page template contains a different custom post type. The posts from the loops can be loaded by AJAX to load more. This is the common code that I run ...
Mathieu Préaud's user avatar
0 votes
3 answers
83 views

Display articles with a different template in the home page | Solved |

I am creating a theme for my site. I would like to display the last 5 articles on the home page but with a different display for the first articles. So I created this code that I try to tweak but ...
Outkax's user avatar
  • 1
0 votes
1 answer
195 views

in_array not working on dev server but works on localhost

I've written a loop which works on my local machine but not on my dev server. My dev server is running PHP 7.4.13 and my MAMPRO is running 7.4.12. The dev server code displays nothing and with no ...
Amesey's user avatar
  • 125
0 votes
0 answers
411 views

How to Create Carousel Indicators in PHP Loop using wp_get_attachment_url function?

I am trying to Create Carousel Slider in which Images get from the wp_get_attachment_image_url function and all other alt title and caption data it works correctly. I am stuck at carousel Indicators I ...
stepiadm's user avatar
0 votes
1 answer
563 views

Show ACF field with link to ultimate member profile/Wordpress user profile below the post (single post layout)

I'm using Advanced Custom Fields and I'm trying to show a custom field below the single post. I managed to get the code to render below the post, but when I set the field movie_actors and save, the ...
023023's user avatar
  • 135
0 votes
0 answers
26 views

How to output the taxonomies that are assigned to each custom post?

I'm trying to loop through all custom posts and output the taxonomies that are assigned to each post. The code below is currently just outputting every taxonomy available to the post, even if it isn't ...
user205498's user avatar
1 vote
1 answer
69 views

Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?

I currently have a Portfolio custom page in Wordpress, so far work as i want, but i have one problem. The problem is when i click one of the button slug then the body/output is not work like i want, ...
N. Arifin's user avatar
0 votes
2 answers
163 views

Wordpress query undefined offset in loop

I created a query with arguments see blow. On the page I see an error in a loop Notice undefined offset 1 Notice undefined offset 2 Notice undefined offset 3 and so on... $args = array ( '...
Stefan's user avatar
  • 3
0 votes
1 answer
237 views

Pagination not working in custom post type. Help

I am currently working on an eCommerce project where I am coding a non-WooCommerce dependent theme for eCommerce. The current problem with me is, I am coding archive-product.php which is a custom post ...
Chotu Kaalia's user avatar
1 vote
1 answer
317 views

Use object in template part

I try to use a template part in my loop. <?php foreach ($categories as $category) { get_template_part( 'temp-parts/loop/blcnr_loop'); } ?> In the template part I call the object <?php ...
Jop's user avatar
  • 127
0 votes
0 answers
109 views

Get title of page containing post grid within the posts

I have a page containing a post grid. Within the text of these posts I want to use a shortcode to display the title of the page containing this grid. So, when my page title is "test" I want ...
marjoleins's user avatar
0 votes
0 answers
318 views

Check if current post in loop is last on current page

I am developing a WordPress theme and want to determine if I am at the last post of the current loop page. <?php get_header(); ?> <main id="main"> <!-- ======= Blog ...
Isakiye Afasha's user avatar
0 votes
0 answers
49 views

delete an array element when its date expires

I have user levels for access content. I made a start date and end date input for each other. Each level has its own history. Whichever level date exceeds today's date, it will be removed from user ...
freedom667's user avatar
0 votes
1 answer
1k views

update_user_meta as multiple value but with same meta key

I have this code. When I save it, the user levels adding and gives time select input next to it. But when I give different time to levels, for example: Level 1: 2 weeks, Level 2: 9 Months If saves ...
freedom667's user avatar
0 votes
0 answers
22 views

Is there anyway I can call the year once?

Hi everyone I hope you have a great day, I was wondering if is there anyway I can call the year once?. I really don't know if its possible to call the date once cause mine keeps on repeating calling ...
jricc russel's user avatar
0 votes
1 answer
27 views

when looping through custom post data not appearing

i have a loop that fetch custom post type from the database now when i go to the page the data doesnt appear but when i refresh the page 2 times the data shows here is the code: <div class=&...
Or Shalmayev's user avatar
2 votes
1 answer
276 views

How do you output custom code between posts in the loop?

I am trying to put a header before past posts and after future posts. I'm using get_posts() in a function to output the posts using a foreach loop for a custom post type ordered by date (meta key). If ...
Confused One's user avatar
0 votes
1 answer
779 views

Display all categories including sub categories under a list ul

This code is displaying only categories, how can I change to also include subcategories. Thanks Thanks, with this code is listing all together, I want that shows like this Category 1 ...
Carlos's user avatar
  • 1
0 votes
1 answer
398 views

How to pass a variable to get_template_part that's updated every time the template part is called?

I have a loop and in that loop I use a get_template_part to call the HTMl for the post to display. I also have a variable (number) to which +1 is added every time the loop runs. In this way I can ...
ralphjsmit's user avatar
0 votes
1 answer
522 views

Responsive loop with 3 columns inside row then 2 columns

I created a loop in my archive page displaying the posts in 3 columns (33% width) inside a row with 100% width. Each column is a post. What I would like to achieve is to make the loop more flexible ...
Mathieu Préaud's user avatar
0 votes
1 answer
28 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'...
RLM's user avatar
  • 247
2 votes
1 answer
2k 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 ...
RLM's user avatar
  • 247
0 votes
1 answer
305 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 ...
Robert L's user avatar
0 votes
0 answers
25 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 ...
BobTheBuilder's user avatar
-1 votes
1 answer
127 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/...
Gene Ellis's user avatar
0 votes
1 answer
35 views

Where does php code to load data go?

I am using the example at populate dropdown wordpress form from database custom table. I understand the code but I do not know how to execute it. This code should be executed whenever a new Post is ...
GreatDayDan's user avatar
0 votes
1 answer
9k views

Adding new divs with custom classes to products on WooCommerce shop page [closed]

In a custom Wordpress theme I need to display product image and product summary side by side on the WooCommerce shop page, so I am trying to add new divs with custom Bootstrap classes; I used ...
Andy Blinde's user avatar
0 votes
1 answer
955 views

Issue with custom loop in Archive page

I customized my loop in archive.php to display 8 posts per page. However I have an issue passing the args: the loop displays all my posts from all my categories. Here is my PHP code for the loop: &...
Mathieu Préaud's user avatar

1
2 3 4 5
9