All Questions
123 questions
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, ...
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 ...
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 ...
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 ...
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()
{
...
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 ...
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 ...
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 ...
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 ...
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:...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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() { ...
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" ...
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-&...
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 ...
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 ...
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)
{
...
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>
<...
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”...
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 ...
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' => '...
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 ...
-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 ...
-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 ...
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 ...
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....
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 ...
-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 ...
-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 ...
-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"';}>...
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/...
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)...
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 ...
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 ...
-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() )...
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:...
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 ...
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 $...
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?
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 ...
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 ...
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",
"@...
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;" <?...
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 (...
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 ...