Questions tagged [php]

For questions about the server-side programming language that the WordPress core, plugins and themes are written in. Questions about using PHP outside a WordPress context are off-topic but might be asked on Stack Overflow.

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

Change image data durgin upload

I try to change image filename and image meta during upload to media library. I have a problem with create unique filename hence, a bad slug is generated. Also, during upload, file uploaded by this ...
user avatar
  • 1
1 vote
0 answers
23 views

How to combine wordpress_logged_in cookies in one cookie?

I'm trying to optimize my server to consume less resources as possible and increase overall performance. In my site I don't see a need to recompute same requests for users or guests every time. The ...
user avatar
  • 111
0 votes
0 answers
14 views

How to WP_Query posts order by parent title?

How do I return a posts from WP_Query ordered by their parent's title? I know how to do it in the way where I return ALL posts and then change the order afterwards with array sorting. But I wanna know ...
user avatar
0 votes
0 answers
16 views

Prevent Buddypress Rewrite Rules on Non-Buddypress pages/posts

(Edit: Like one of the links below mentioned, it has to do with the order in which the Matching Rule is called, the more engagement/traffic/activity a BP page gets, the more the rewrite rule is called ...
user avatar
2 votes
0 answers
36 views

Hide categories that are not used in the post type

I have a situation where I need to display categories on the Archive Page of CPTs, but if the category is not used anywhere in the CPT, it needs to be excluded from the list. For example, I have a CPT ...
user avatar
0 votes
0 answers
17 views

how to get sentence values from wordpress shortcode parameter?

I've set up a shortcode that gets sentence value from parameter, but it only returns the first word of the sentence. I've assumed that the shortcode recognizes values after whitespaces, but when I use ...
user avatar
0 votes
0 answers
31 views

How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?

I want to structure my Plugin folder & file system in a way, where in add_submenu_page when I will click on my sub menu link it will call separate .php file where i will car specific function ...
user avatar
0 votes
0 answers
15 views

Disable send password change email to user wordpress

I create custom registration for registration process. In here first step I used email for register user. Once user verify his email he can continue his registration process. Once user enter his email ...
user avatar
0 votes
1 answer
9 views

How do I reset $wp_query in a function?

I'm using a function in my functions.php that finds a specific post in a custom post type depending on a slug. I was wondering if I need to reset $wp_query because I use $wp_query = $posts and $...
user avatar
  • 1
0 votes
1 answer
14 views

Change product_base programmatically

I'm building a plugin that will be introducing and managing/handling a new product type (like Simple, Variable, etc), and I want to also change the product_base permalink from product to that new ...
user avatar
  • 121
0 votes
0 answers
9 views

Add class to all img if they have a certain ACF field

I have an ACF field for image attachments so the user can choose 'rounded border' or 'square border'. How can I apply a class to all images depending on the value of that ACF field? I can do it if the ...
user avatar
0 votes
0 answers
12 views

Woocommerce order status payment

I have some issue with Woocommerce client already do the payment, but then i see as order pending payment, but this should be in order status processing thats the default settings
user avatar
0 votes
1 answer
54 views

Pagination in single.php

I have a problem with the pagination on a single.php page. The idea is to have a list of my created posts (the excert, the title and a link to the post) on the post page (single.php) that shares the ...
user avatar
  • 3
0 votes
1 answer
49 views

Custom plugin settings link doesn't append current class to menu item when visited? Why?

So I've created a custom setting link on my plugin listing, that takes the user to the plugin settings. However, it doesn't seem to be working as I would expect it to and I'm not sure why. 🤨 To ...
user avatar
  • 91
0 votes
0 answers
16 views

Fetch data from two custom post types and create multidimensional array for output to html table

I have two CPT (brochures and brochures_so). In both CPT i use ACF field (key = jaar) brochures Jaar (ACF field) Vakgebied (Custom taxonomy) 2021 Wiskunde 2022 PAV 2022 Frans brochures_so Jaar (...
user avatar
  • 101
0 votes
0 answers
40 views

Why wp_remote_get() fetches certain web pages while it doesn't work for my localhost?

Why I'm not able to parse csv files (or equivalently open them) using WordPress shortcode? Problem: I wish to use a shortcode to Parse Contents of a csv file and display its contents effectively. But ...
user avatar
1 vote
0 answers
44 views

Wordpress Shortcode to get URL Parameters $_GET['name'] redirects for no reason at all

Need some help in understanding how does WordPress Redirects work. While working with shortcode: add_shortcode('name', 'get_name'); function get_name() { return $_GET['name']; } The page which ...
user avatar
0 votes
0 answers
24 views

WP Container Displaying Only on First Page of Archive

I have the following code for a two-column container: <div class="rh_content rh_content_above_footer rh_page__content"> <div class="wp-container-3 wp-block-...
user avatar
2 votes
0 answers
16 views

Is there CSS to expand the gallery limit on Index Pages?

On a wordpress index page, I am only allowed to add 12 galleries. I would like to add many more. Is there a way that I can expand the gallery limit allowed on index pages? If this is not possible, is ...
user avatar
0 votes
1 answer
25 views

For some time, some of my pages do not display the content anymore. Any idea where this could be coming from?

I recently worked on this website : https://semaine.com/ But since some time the content of the pages https://semaine.com/classroom/ and https://semaine.com/cinema/ are not displayed anymore. The ...
user avatar
  • 1
0 votes
0 answers
19 views

Get product categories and add them to a custom taxonomy

I'm working on a WooCommerce webshop. I have divided all my products into categories. Example: Clothing: -Tshirts -Jeans -Etc. Likewise, all brands are also divided into categories. Example: Brands -...
user avatar
  • 1
0 votes
1 answer
26 views

wp_delete_comment takes two tries to delete - then deletes all comments

I'm trying to add a button to my comments that allows a user to delete them. I have a form declared like so: <form method="post"> <input type="submit" name="btn-...
user avatar
0 votes
1 answer
14 views

Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?

I'm trying to create a dropdown selector on my CPT and CT archive page for a custom taxonomy called "location". I've managed to get the form to submit, however, it does not direct me to the ...
user avatar
0 votes
1 answer
18 views

Links to previous/next month archives

On the month archive page (using the date.php template), how can I add links for the previous month and next month? For example, viewing January 2022 (/2022/01), I'd like a link to December 2021 (/...
user avatar
0 votes
1 answer
577 views

WordPress 6.0 class-wp-widget.php fatal errors in PHP 8.1.6

/wp-includes/class-wp-widget.php gives me an error for one blog, but not the other, and both have the same version of class-wp-widget.php which makes no sense to me. PHP Fatal error: Uncaught ...
user avatar
  • 431
0 votes
0 answers
25 views

search.php to search only the post title

I'm trying to rewrite my search.php to search only for the post titles because I have a ton of posts published to my site (around 400k), which slows down the search speed to about 20s per search. <?...
user avatar
0 votes
0 answers
51 views

How to Insert Ads After Every X Paragraph PHP

I am currently using this code to insert Ads after the 5th paragraph and it works just fine. //Insert ads after fifth paragraph add_filter( 'the_content', 'prefix_insert_post_ads' ); function ...
user avatar
0 votes
1 answer
52 views

How to use wp_send_json() and output the value with ajax?

Hello Wordpress Developers. I create my own plugins, and I'm stuck about how to call php functions inside class, into javascript ajax functions. For example we have button with ID name clickme: <...
user avatar
  • 5
0 votes
0 answers
23 views

Getting text from custom field from customizer

So I've created a panel in the customizer section in WordPress to add the phone number to the site. It works fine in the back end but it wont show up in the front end here is my functions.php ...
user avatar
  • 5
0 votes
1 answer
52 views

Unserialize Custom Field & Save as Multiple Rows in Wordpress Database

I have a custom field in post_meta table of wordpress database. It's called 'combined'. I want to seperate the values based on key and save them as multiple rows if there are multiple values for the ...
user avatar
0 votes
0 answers
53 views

Workaround for og:image unsupported webp image type, Yoast SEO?

My site Beta Fox uses Yoast SEO plugin to help deal with SEO common practices, however an issue has arisen. In beginning of last year WordPress didn't fully support webp image types, neither Yoast SEO....
user avatar
  • 111
0 votes
0 answers
10 views

Comment Reply Link Reloading Page Instead of Moving Comment Form [duplicate]

In my comments.php, I loop through the comments like this: if (have_comments()) : ?> <ol class="post-comments"> <?php wp_list_comments(array( '...
user avatar
0 votes
0 answers
16 views

How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes '&' to '#038;'?

I use a quick redirects plugin and it's changing my URLs after the fact and thereby breaking some of my links. I never want wordpress to change & to #038;. There is an unwanted solution to turn ...
user avatar
  • 130
0 votes
1 answer
32 views

How to properly replace the_content with the html in a php file?

I've built a plugin that needs to overwrite the content on a specific page. It works, but it places all head content within the body, after my own html. Is there a way to fix that? add_filter('...
user avatar
  • 1
0 votes
0 answers
27 views

Hook on file upload

I need a hook or some way to detect when the window to select the file to upload is opened. I'm talking about the window that opens the browser to select the local files to upload. Context: On ...
user avatar
  • 17
0 votes
0 answers
10 views

How to change the author box selection on a post to a custom taxonomy

So instead of the author section pulling in 'Users', I need to change it so that the author box displays a selection of the terms from a custom taxonomy I have made. Is this possible to change?
user avatar
0 votes
1 answer
161 views

Why is $wp->request empty in Wordpress 6.0?

Trying to obtain the page url with the following code prior to Wordpress 6.0 works, but after update to Wordpress 6.0, $wp->request is coming through as an empty string on all pages. I have Post ...
user avatar
0 votes
1 answer
21 views

WordPress navigation wont appear with wp_head

so im building a custom theme and ive got stuck on the navigation if i use wp_head(); it loads bootstrap and my custom style sheet but not the navigation if i use get_header(); it loads the navigation ...
user avatar
  • 5
0 votes
1 answer
21 views

Contact Form 7 Wordpress, checking a few fields, if empty then invalid

Could someone help me to solve the problem. I would like the system work like bellow. If both fields are empty = invalid. If any of the fields is completed = valid add_filter('wpcf7_validate_text', '...
user avatar
  • 1
0 votes
0 answers
21 views

WordPress get last inserted user id

I want to disable user_login field into my CMS. They are register only their email adress. I think to create secret user login by programmatically. I think for accessibility and manageability also I ...
user avatar
  • 278
0 votes
0 answers
18 views

Dynamically added custom fields not displayed on WooCommerce email notifications

I have a different kind of scenario then the typical custom fields (I suppose). I am not getting custom values (fields) from user in the form rather I have an implementation which adds: ColorName ...
user avatar
0 votes
0 answers
20 views

How do you remove header sitewide from mobile only?

I'm having trouble hiding my header on mobile devices. My wordpress theme does not have an option to hide it, so I was looking at the theme's header.php file if there was anything I could add to it. ...
user avatar
0 votes
1 answer
27 views

Assigning a category to a custom post type in Wordpress

I am working with custom posts to create a 'document' custom post type and then trying to assign the category during wp_insert_post, have tried using both post_category and tax_input to no success. I ...
user avatar
0 votes
0 answers
39 views

WordPress: Export/Import Yoast meta title & description to custom taxonomy

I want to export the Yoast meta title & description from a custom taxonomy with the WP All Export. Unfortunately there is no direct way with the plugin to do that. There is an extra WP All Export ...
user avatar
  • 145
0 votes
0 answers
19 views

End of blog roll or start of blog roll, _post_link = false / no link

Please help, how do you write this if next_post_link() = false / no link or end of blog roll : do this; else : return; endif;
user avatar
0 votes
0 answers
42 views

Modify WooCommerce used to get all orders in dashboard

The existing WooCommerce orders table in the wp-admin dashboard orders the results by the date the order was made, but I want to modify the query to order by date and also by the shipping method of ...
user avatar
  • 101
0 votes
1 answer
27 views

Show Featured Image Dimensions and size frontend with shortcode

I was wondering if I can show my featured image Dimensions (W x H in px) and the filesize in mb. In my Wordpress post with a shortcode. thank you in advance :)
user avatar
0 votes
1 answer
33 views

php redirect with custom user roles set and working but redirect not working for when users are logged in

I have created code to add custom user rules. It works. However when I try to tie in the code for redirecting an already logged in user based on one test role, then it doesn't work. What am I missing ...
user avatar
  • 13
0 votes
1 answer
35 views

How to Add text value in Automatically in this conditions?

**how to input a text value in this conditions automatically , when user input text fields value ** **which condition do I apply ? ** code was added :
user avatar
  • 1
0 votes
1 answer
30 views

Let current user know pending posts counts using wp_query

I'm working on a query to let a logged-in user know if the user has more than 5 pending posts. Here's what I ended up with: // Start the query $query = new WP_Query( array( 'post_type' => '...
user avatar
  • 175