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.
10,543
questions
0
votes
0
answers
18
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 ...
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 ...
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 ...
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 ...
0
votes
1
answer
18
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 ...
-1
votes
0
answers
13
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 ...
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 ...
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 ...
0
votes
1
answer
25
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, ...
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 ...
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 = ...
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,
'...
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) ...
0
votes
1
answer
30
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 ...
1
vote
1
answer
34
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 ...