Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
20 views

WordPress current post functions inside loop doesn't work anymore, are they incompatible with php 8.0?

I recently update php from 7.4 to 8.0 , since many functions doesn't work anymore ! I don't know if it's related but I have tried many solutions and none of them works. Using (get_...) , the_title, ...
imagIne's user avatar
  • 105
0 votes
0 answers
91 views

Update post meta with wp cron

I am trying to create a function (which I will trigger through the WP Cron) but no values are passed and the database values remain NULL. Could anyone point me in the right direction of where I'm ...
Rein's user avatar
  • 1
0 votes
0 answers
167 views

Get full slug for a Wordpress Post

I am using this code to get the URL of a post which is subsequently used as input on a form field. global $post;$post_slug = $post->post_name;$post_slug = urlencode($post_slug); However, this ...
JoaMika's user avatar
  • 698
0 votes
1 answer
231 views

Add custom text automatically on each post

Suppose I have a post and it's the first paragraph is: "This a Pen. The color is red." I want to add a custom text like "2022" after "Pen" on first sentence, at the end ...
Mi Monir's user avatar
1 vote
0 answers
70 views

Getting different functions data while using while loop in wordpress

I have added this code in the function.php file but when I use while loop in any other files this function is getting triggered. <?php add_action('loop_start', 'userlogin'); function userlogin() { ...
Nabeen's user avatar
  • 11
0 votes
2 answers
2k views

the_date() and the_time() functions display actual date an time instead of published date and time

It's really hilarious but my the_date() and the_time() functions show the current date and time instead of the post's publication time, therefore at each refresh of the page, the time changes ...
T3mmX's user avatar
  • 23
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
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
50 views

Exclude category from

I am trying to exclude a category from <?php the_category(', ') ?> inside my loop. I came across the following code on CSS tricks that says would solve the problem. You add this to the functions:...
Ed Manson's user avatar
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
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
1 answer
463 views

issue with if/elseif in_array inside foreach loop display only one post

I try to attribute a specific background-color to each post if one of categories of post corresponding to one category. My function works but is restricted to display only one post in result. If I ...
imagIne's user avatar
  • 105
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
1 vote
0 answers
329 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 ...
Sioban's user avatar
  • 11
0 votes
1 answer
39 views

How set a while with a function

i have a simple function and i need that while it execute my function it set a variable to true, otherwise false. the execution would be my condition. while run this func function need() { ...
DevBeppe's user avatar
0 votes
1 answer
2k views

cURL needing to loop through all "next_page"

When using cURL, how would I be able to include a call inside my get_all that basically will loop through all the next_pages, get the data and then outpul it to $response->data when the "next_page" ...
DevSem's user avatar
  • 209
0 votes
0 answers
127 views

Custom query for custom post type not getting correct post ID

I have written a custom query here: <?php $the_query = new WP_Query( array('post_type' => 'video', 'posts_per_page' => 10, 'post_status' => 'publish') ); ?> <?php if ( $the_query-&...
WordCent's user avatar
  • 1,877
0 votes
1 answer
149 views

Pass post ID from archive template to functions file

I have an archive template where I am displaying a "featured post" at the top of the page. I am building my post loop for the rest of the page in the functions.php file. What I would like to do is get ...
user13286's user avatar
  • 227
1 vote
1 answer
449 views

get author_name from queried post

All I'm trying to do is, get the author name of the current post and set it's name as a tag. I tried changing author_id to author_name but didn't really get anything back. wp_set_post_tags should ...
J patel's user avatar
  • 15
0 votes
2 answers
91 views

use loop to return blog details

I want to return information about a blog. It could be, author name, title, date, country whatever just to test. <?php $post_id = get_the_ID(); while ($post_id != 0) { ...
J patel's user avatar
  • 15
1 vote
1 answer
777 views

Get first URL from post content

Basically all I want to do is if the post format is "link" rather than link to the post from the blog index, link to the link pasted within the post content. In my index.php I have: <h3> <...
caffeinehigh's user avatar
0 votes
2 answers
284 views

WordPress Ajax filter: Create two loops for different output styles?

I have two different pages, with filters. Those two pages, have different layouts and styles. I have three different filters for one page, where the output and style is the same. For the “newsfilter”...
Thomas Tromp's user avatar
0 votes
1 answer
22 views

Prevent function from triggering on current page

I created a list of posts, each post about a car model. After that, I created a post about the best car models. This post grabs each post about every car model and displays them in a snippet list ...
Richarpower's user avatar
0 votes
2 answers
31 views

Where paramaters of a custom function are coming from inside the loop?

I have this piece of code and, although it works, I do not understand how. First, I created a custom post type into my mu-plugins folder: function actor_init() { $args = array( 'label' => '...
Enrico's user avatar
  • 109
1 vote
1 answer
8k views

How to get current post category details inside "loop"?

I have a rather simple problem I can't solve. I have custom styling for my cards and one of the elements of the cards is the category, when I access the_category() from the Loop it comes with its own ...
Mark20's user avatar
  • 17
-1 votes
1 answer
2k 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 ...
Agreesh V S's user avatar
-1 votes
1 answer
30 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 ...
user avatar
0 votes
0 answers
965 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 ...
Peter's user avatar
  • 135
0 votes
2 answers
960 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....
BruceWayne's user avatar
0 votes
0 answers
39 views

subtracting the current post form then whole loop, which is generating all CPT titles

<select class="title_select minimal"> <?php $loop = new WP_Query( array( 'post_type' => 'plugin', 'posts_per_page' => -1 ) ); ?> <?php ...
WordCent's user avatar
  • 1,877
-1 votes
1 answer
74 views

How to write a query-function as a query-shortcode?

I ask this question as a follow-up to this one. I have this query-function in functions.php but AAMOF I don't want to change functions.php at all (besides for CPTs). I'd like to print the same data ...
Ben's user avatar
  • 1
-2 votes
1 answer
35 views

Creating mixture of shortcodes to use in the visual/text editor

I am attempting to make a page on my site that has a mixture of different kinds of content. So I'd like for the first part to just be the_content, but then beneath it calls to posts under specific ...
eightnaut's user avatar
-1 votes
1 answer
5k views

Parse error: syntax error, unexpected 'endforeach' (T_ENDFOREACH) in [closed]

<ul class="project-extension-side-link"> <?php foreach($projectextensions as $projectextension){?> <li <?php if($section=='project-extension') {echo 'class="active"';}>...
Gaurang Suthar's user avatar
4 votes
1 answer
5k views

AJAX handler throws 400 (Bad request) - why?

I am trying to apply a "Load more posts" function to a post loop, but I am dealing with a 400 Bad request, when admin-ajax.php is referred to. The reference I used is this - https://rudrastyh.com/...
Dougless's user avatar
2 votes
1 answer
5k views

Adding WooCommerce to a Custom Theme - not working [closed]

I have a custom Wordpress theme I'm doing for a client and I need to make it woo-commerce compatible. I've followed the steps on the woocommerce docs which are: 1) create a woocommerce.php file 2)...
pjk_ok's user avatar
  • 908
0 votes
1 answer
25 views

Change all author links in Blog roll

I want all the author links on my blog page to go to a specific url ("/about") instead of the individual author pages. I know this can be done easily with JavaScript, but is there way to do it in ...
AJT's user avatar
  • 187
2 votes
0 answers
6k views

Display WooCommerce subscriptions for user [closed]

I'm trying to display a user's Subscriptions within their WooCommerce dashboard. I am able to do this, but I also want to add some additional fields related to the Subscription (title, next renewal ...
Garconis's user avatar
  • 144
-2 votes
1 answer
179 views

Loop on a wordpress Page instead of content coming from the WP text editor

I have created a page template: <?php /* Template Name: homedefault */ ?> But Instead of text coming from here i.e. wp editor: I want it to come from the loop: <?php if ( have_posts() )...
WordCent's user avatar
  • 1,877
0 votes
2 answers
1k views

How to sort (orderby) a query done by a template function before the 'foreach' loop?

How can I sort an array of elements being hold on a query done by a template function, just before the output starts on a foreach loop? I wanted to order my elements by the Post Title. Here is my code:...
Mateus Oliveira's user avatar
0 votes
1 answer
225 views

Genesis Framework: How to exclude a specific author from archive custom loop

I am using the Genesis Framework on my website, and have added the following code to my functions.php to customize the archive loop. //* Archive Custom Loop function archive_custom_loop() { echo ...
Angelos Kyritsis's user avatar
1 vote
2 answers
5k views

Problem with calling custom function in a foreach loop

I have a custom function in functions.php that excludes specific category from the category list: function incomplete_cat_list() { $first_time = 1; foreach((get_the_category()) as $...
Anda's user avatar
  • 57
11 votes
1 answer
16k views

What is This esc_html_e() i wordpress php?

why do developers use <?php esc_html_e() >? in 404 pages, what does it mean, how does it works?
TheDose's user avatar
  • 198
0 votes
1 answer
85 views

Custom Pagination is Broken

Good Afternoon! I am working on adding pagination to a website and currently it is working fine but for some reason the function loads an extra page. We have 7 posts, and I set it to display 4 posts ...
NeoLobster's user avatar
1 vote
0 answers
41 views

Blog posts repeat

Good Afternoon! I have having an issue on a site I am working on where in that the blog posts "repeat" and by that I mean they are being displayed twice. Ideally I would like the page to work as ...
NeoLobster's user avatar
0 votes
2 answers
3k views

Loop increase number

$args = array( 'post_type' => 'events', 'order' => 'ASC', ); $wp_query = new WP_Query($args); ?> <script type="application/ld+json"> { "@context":"http://schema.org", "@...
Juan David's user avatar
1 vote
1 answer
56 views

Converting a dynamic piece of code using WordPress Loop into a static one using Post ID

<?php if (is_single()) { ?> <?php $imvi = get_post_meta(get_the_ID(), 't_puck_imvi', true); ?> <div class="class1" <?php if( 'none' === $imvi) { ?> style="display:none;" <?...
WordCent's user avatar
  • 1,877
2 votes
0 answers
1k views

How to use max and min values of custom fields

How to use max and min values of custom fields (created via ACF, repeater type)? For axample, I've custom post type 'auto' and there are a lot of models. Each post(model) has few values of price (...
Влад's user avatar
0 votes
3 answers
2k views

Get post id outside loop : Notice: Trying to get property of non-object

I am trying to get the post id outside the loop in functions.php.but what error i am getting : Notice: Trying to get property of non-object in functions.php on line 549 function ...
hamidable's user avatar