Skip to main content

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.

0 votes
1 answer
12 views

Is there a way to get a path to the theme directory without the server name?

I need to use file_get_contents() in my theme to include an SVG file. As far as I know, an obvious way to do this would be the following: file_get_contents("https://example.com/wp-content/themes/...
Ivan Vetoshkin's user avatar
0 votes
0 answers
8 views

Capture the Selected Radio Button Value between two files in wordpress theme

$html_output .= '<div class="form-group"> <label><input type="radio" name="driver_type" value="society" checked required> ...
amine asfar's user avatar
0 votes
0 answers
24 views

Changing upload directory temporarily

I have various media file uploads that I need to section off into different subdirectories, for example: example.com/assets/Uploads example.com/assets/team They all go under "/assets" but if ...
user1702965's user avatar
2 votes
0 answers
13 views

Custom Search Function in WordPress Returns No Results

I'm trying to integrate a custom search function in my WordPress site where an external API is used to determine search results. The function is supposed to retrieve a list of post IDs from the API ...
Juned Adenwalla's user avatar
0 votes
1 answer
15 views

What is different about using admin-ajax.php in an endpoint and just submitting a form from the front end?

I have created an endpoint with the following php code. The code is currently allowing me to receive the correct pdf but none of the information from the $page is populated in the pdf. The $page is a ...
holty07's user avatar
0 votes
1 answer
12 views

Processing data and redirecting with query string

I am a WordPress and PHP newbie, or at least I haven't coded any PHP since PHP 5 (about 12 years). Our site needs a custom thank you page with a form embedded. I have done all the research I can and ...
pacmaninbw's user avatar
0 votes
1 answer
19 views

What is considered good practice for registering menu locations?

I decided to try my hand at creating my own WP theme from scratch. I've made a header, a navbar, and a footer so far. I've also registered a couple menus, so my navbar will be populated automatically ...
ArceusLegend50's user avatar
-1 votes
0 answers
14 views

blocked by CORS policy

I get error Access to fetch at '' from origin '' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on ...
Batuhan Özkan's user avatar
0 votes
0 answers
21 views

Getting table to format properly in RSS feed emails

I have a post with a tablepress table with many columns. When the post is added to RSS, Mailchimp emails it out, but the table is jumbled due to the many columns squeezed together. I found the table ...
somuser's user avatar
0 votes
0 answers
25 views

Hiding posts from main page/archive but not RSS feed [duplicate]

I'm trying to hide certain posts (either by ID or category) from my site's main post list, archive post list, and the custom search feature, -but- I need those posts to still show up in RSS feed. I've ...
somuser's user avatar
0 votes
1 answer
29 views

PHP Deprecated function Optional parameter $function

I get messages in the debug.log for PHP Deprecated: Optional parameter $function declared before required parameter $page is implicitly treated as a required parameter code function add_meta_box($id, ...
Vincenzo Piromalli's user avatar
0 votes
1 answer
24 views

Cannot register a custom WP-CLI command

I am working on a custom plugin and one of it's functionailities is to scan all the posts/pages on daily basis and update a meta-data in the database. I also wanted to create a custom WP-CLI command ...
Farhan Ali's user avatar
0 votes
1 answer
23 views

Show numbers of related post based on sub category and HIDE parent category

I removed my prev question since I have found the solution and it works as expected. Here's the code to show numbers of related posts based on sub category (cat child): <?php $categories = ...
ArduJimmy's user avatar
0 votes
0 answers
21 views

WordPress Create New Role Just to Manage Users?

I'm trying to create a new role where the only thing this role can do is manage/add/edit/delete users in the admin. add_role('test_role', 'TEST Role', array( 'read' => true, '...
Jon's user avatar
  • 313
0 votes
1 answer
8 views

Add an attribute on WP images attachment link

I have to add an attribute on WP images to add description on Spotlight lightbox. I tried the wp_get_attachment_link filter but it doesn't work. function add_data_description_link($content, $post_id) ...
Stefano's user avatar
0 votes
1 answer
32 views

how to escape alert/window.location.replace with variable

I'm trying to write my first WordPress plugin and despite reading the documentation about escaping and reviewing other people's questions and answers I'm still not clear on how to do it in 2 cases the ...
Eitan's user avatar
  • 3
1 vote
1 answer
36 views

How to send user password reset link to their phone number instead of email

I want to send user password reset link to their phone number instead of email. I can use Twillo to send sms process. I tried below code but there is an error. Any suggestions ? function ...
Buddika's user avatar
  • 11
0 votes
2 answers
43 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
0 votes
1 answer
39 views

WordPress CPT & Custom Taxonomy with the SAME Permalink Structure

I have a CPT: 'Guide' and Custom Taxonomy 'Guide Category'. What I want to achieve is: The CPT permalink structure is: example.com/guides/custom-taxonomy/post-name/ So that the following should ...
Elgameel's user avatar
0 votes
1 answer
48 views

Is there a way to pull remotely generated XML, process it, and display it on a Managed WordPress page?

Note: This is cross-posted on stackoverflow. I need to get some XSQL generated XML data from a remote server, process it, and display it on a GoDaddy Managed WordPress page. (This is the website my ...
Giric Red Wolf's user avatar
0 votes
1 answer
59 views

How to automatically flush permalinks?

Is it possible to write function that will trigger flush_rewrite_rules() on a timer? I would like for it to run every hour
John Saputo's user avatar
0 votes
1 answer
37 views

Adding extra cost to woocommerce flat rate based on shipping zone

i found solution here to count flat rate based on specific quantity steps in woocommerce, what i need additionally to add an extra specific amount based on shipping zone. for example : i charged ...
Shehab Zahran's user avatar
0 votes
1 answer
38 views

cURL running slow in Wordpress

I have the following code in one of my Wordpress page templates: $url = "https://xxxxxxxxxxxxxxx/"; $headers = array( 'Accept: application/json', 'Content-Type: application/json', ); $...
user1448031's user avatar
0 votes
0 answers
25 views

I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)

//this is my functions.php // Enqueue Styles function meraboiler_enqueue_styles() { wp_enqueue_style('google-fonts', 'https://fonts.googleapis.com/css2?family=Patua+One&family=Open+Sans:wght@...
Kashkumar Singh's user avatar
0 votes
0 answers
19 views

Show post in elementor based on views and specific category with query id feature in elementor

I have two functions for query filter: function my_query_filter_most_views( $query ) { $query->set( 'orderby', 'meta_value_num' ); $query->set( 'meta_key', 'entry_views' ); $...
Danial Sohail's user avatar
0 votes
0 answers
19 views

I want to move the one click accesbility button on bottom of my website screen,

I want to move the one-click accessibility button on bottom of my website screen,Kindly give me a code for that
user243103's user avatar
0 votes
0 answers
33 views

How can I display a Divi content inside a modal based on an AJAX request

This is my first question, please bear with me if I have forgotten any information. I want to show Divi content (saved as a WordPress project if it's important) inside an overlayed modal. For this I ...
cho's user avatar
  • 1
0 votes
0 answers
19 views

Start a long running PHP process via JS/Ajax and monitor progress on admin page

I am developing a plugin, which can import layouts for a certain theme from a remote URL. Those layouts often contain a good amount of images and sometimes even videos. I have a admin page where the ...
xxtesaxx's user avatar
  • 101
0 votes
1 answer
19 views

If user is Admin or another role

I have this code, which works perfectly: if (in_array('administrator', $user->roles)) { I need it to also check for another role, so that it would be an, 'if this or that' scenario, such as, ...
BarkingBird's user avatar
0 votes
0 answers
16 views

Endpoint exists and shows up in My Account dashboard. Need to add endpoint to My Account DROPDOWN menu in Porto theme

NOTE: StackOverflow closed this question claiming it was a duplicate but there isn't any similar questions. I looked through the other "similar" questions but those were in regards to adding ...
Mr. Victor's user avatar
0 votes
0 answers
20 views

Adding features to Gutenberg without theme.json

I am using a non-block theme for my website and am using Gutenberg for writing posts. I want to extend Gutenberg's functionality by adding the image lightbox feature. So I added a theme.json file to ...
Ryan's user avatar
  • 1
0 votes
0 answers
15 views

Wordpress : how to create onglet and remove it when only one

I have two extensions : Core where there all the common files and Wooster extension in Wordpress. In Wooster extension I have WoosterPartnerSetup.php and in the Core WoosterSetup.php. I am trying to ...
OceaneEMILE's user avatar
-1 votes
2 answers
53 views

How to improve the performance when using a flat-file dataset and PHP for implementing advanced search function?

I have to add some advanced search function to a WordPress website, I can't use SQLite database because we are not allowed to install any driver on the system. I solved the issue using a CSV file that ...
G M's user avatar
  • 49
0 votes
0 answers
20 views

Connection refused by Wordpress

I'm experiencing a complicated problem that I'm looking for help on. I have Wordpress served by Apache2 on a Raspberry Pi. I have a domain name with the DNS appropriately pointed to the server. I can ...
Justin's user avatar
  • 1
0 votes
0 answers
8 views

WordPress Customizer - How to save list of checkbox of pages?

I'm trying to create an option within the customizer that is basically a list of pages with checkboxes. I have that part working but I don't understand how to save it AND how to retrieve the saved ...
Jon's user avatar
  • 313
0 votes
1 answer
25 views

WordPress Customizer add_control Dropdown of Pages with Multi Select?

I have a customizer option that simply creates a dropdown populated with pages from the site. I need this dropdown to have the ability for multiple selections? Any ideas? $wp_customize->...
Jon's user avatar
  • 313
0 votes
0 answers
30 views

Registering a custom block style

I’m working on my first block theme and it’s giving me a lot of fun. I see there is a registered style in the block style tab to change the background image of the “row” block.. see the attached image ...
thara's user avatar
  • 1
0 votes
1 answer
77 views

Calling a function via a shortcode in javascript

I'm looking to dynamically change the page-comments option based on whether the user clicks a URL. I have two functions to do this: function psb_comment_listener_func(){ echo " <...
pbee's user avatar
  • 5
2 votes
1 answer
66 views

Programmatically convert single classic block to individual blocks via PHP

I am creating some posts via the wp_insert_post() function. When doing so the content gets saved in one big classic block. Is there anyway to force it to save as individual Paragraph blocks instead?
Tommizzy's user avatar
1 vote
0 answers
18 views

How to Dynamically Change the author_base URL Slug by Language in WordPress?

I am working on a multilingual WordPress site using WPML and I am trying to adjust the author_base URL slug based on the user's language. My goal is to have different slugs for each supported language ...
Robin Martijn's user avatar
0 votes
0 answers
46 views

Using WooCommerce Hooks to add product attribute descriptions to customer order email

My php days are long gone and I'm trying to achieve a "simple" customisation of the order email confirmation (processing and confirmed emails) sent to the customers of a Woocommerce webshop ...
Greg Vdo's user avatar
0 votes
0 answers
14 views

How do I make a shortcode to display Dokan seller badge list?

I am going to add the Dokan seller badge list to the single product page by creating a shortcode so that the tooltip is also displayed. Thank you for your guidance.
negar file's user avatar
0 votes
0 answers
29 views

Redirect to current URL and append specified URL parameter on unsuccessful login through Elementor login form widget

I have the following code running in the Code Snippets plugin, which works the way I need it to work for the most part. Basically I have the Elementor login form in a popup on my website, that way, a ...
David's user avatar
  • 1
0 votes
1 answer
38 views

Get generated block styles programmatically

If you use wp_head() in the header of your theme Wordpress generated a style tag for the Gutenberg block editor. Who knows how you can get the generated css style tag with the styles without using ...
Ruudje's user avatar
  • 21
1 vote
1 answer
64 views

Wordpress Gutenberg Custom Block the viewScript does not get loaded on the frontend when my block is inserted

I recently developed a custom Gutenberg block by utilizing the @wordpress/create-block package, which effectively generated a full plugin framework. I simply needed to tweak some existing files to get ...
Daniel V.'s user avatar
  • 131
1 vote
0 answers
36 views

Custom gutenberg block refuses to load viewScript and I don't know why

I've been struggling with this for hours. I used the @wordpress/create-block package to generate a template for me to create my first block. I've managed to create a hero block with an image uploader ...
Daniel van der Velden's user avatar
0 votes
1 answer
37 views

Adding a css class to the gallery

I'm using WordPress 6.5 with the old editor, I'm trying to add a CSS class on the div gallery when it specified in the shortcode, the code doesn't work, can you help me ? function custom_gallery_class(...
Barrista's user avatar
0 votes
1 answer
35 views

Send emails to individual subscribers when CPT post is deleted (trashed)

The context On my site I have a custom post type (project) where visitors can subscribe to a post and get various notifications via email. My site is hosted locally right now and I am using Mailhog ...
dekkyd's user avatar
  • 7
0 votes
1 answer
31 views

Run a WordPress blog (subdirectory) in a Laravel WebApp - SEO Concerns

I've developed a Laravel WebApplicaiton and now i'm in need of creating a WordPress Blog in a subdirectiory (domain.com/blog) I have concerns regarding SEO and if this new installation with canibalize ...
xake's user avatar
  • 3
1 vote
2 answers
116 views

Image alt tag is showing post title instead of Alt Text

The image alt tag shows the post title in the source instead of the Alt Text. function my_custom_image_sizes() { add_image_size('homepage-thumb', 329, 185, true); } add_action('after_setup_theme', ...
rudyards's user avatar

15 30 50 per page
1
2 3 4 5
211