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
1 vote
1 answer
2k views

Replace shortcode in substring

I've created these two functions to toggle between the first paragraph of the content and then everything but the first paragraph so when the user selects 'More' it slides out the article smoothly ...
0 votes
0 answers
5 views

How to retake a webcam image through phone camera

am creating a form where guests take a picture through their phone camera before submitting the form. So the webcam works well on desktop/computer but on mobile devices I notice when the Retake ...
0 votes
0 answers
17 views

Creating product pages from excel sheet [closed]

Hi I need to create a script or use a plugin which will create product pages from an excel sheet. I have a very limited understanding of wordpress and PHP. And have been struggling with this problem. ...
0 votes
1 answer
888 views

Pagination reset problem

I need a fix for this web page. The page is attached if you wish to review the code. The pagination on each tab does not reset to 1 when the user has made a selection. This needs to reset when they ...
0 votes
2 answers
3k views

Multiple do_shortcode($content) within one shortcode

TLDR; How can I run a shortcode with multiple shortcodes inside of it? I'm trying to run a shortcode with multiple shortcodes inside of it. I can successfully run a shortcode with one shortcode ...
0 votes
1 answer
643 views

duplicate posts with ajax load more wordpress

I have ajax loading posts on my site when scrolling. The problem lies in the appearance of duplicate posts. I cannot understand why this is happening. Only some posts have duplicates. Here is my code ...
6 votes
1 answer
8k views

Woocommerce get selected shipping zone id for the current user

How can I get the selected shipping zone ID based on the current user in WooCommerce? I tried the code below, but I didn't get the zoneID from the cart page: $bh_packages = $cart->...
0 votes
0 answers
7 views

Phone number custom field and woocommerce updating issue noticed

I use Wordpress user frontend plugin to allow guests to post their woocommerce product on my website but I have observed some issues. Firstly, I added a phone number field in the form, then also added ...
0 votes
1 answer
17 views

How to capture number input from wordpress form into acf field in woocommerce

WUFP Phone fieldI am trying to capture the phone number of guests that submit a form on my woocommerce website using the advancedwoocommerce custom field for phone no custom field plugin. I noticed ...
0 votes
1 answer
1k views

Reliable way to add nonce to HTTP Header in WordPress?

I am trying to implement CSP on my wordpress site. Inspired by this question, https://stackoverflow.com/questions/50002041/adding-nonce-to-script-tag I tried to build a way to add nonces to my ...
0 votes
0 answers
10 views

register_rest_route, Compare purchase codes and send a response

I have a question, I would be grateful if someone could help me I am working on WordPress plugins, I have 2 files, the first file is Verification which is for users and the second file is the ...
0 votes
1 answer
899 views

Wordpress ajax filter returning all posts when it should be filtering by category

Here is My code, it should be filtering by category, it displays all posts on any checkbox I click, I don't know how to fix this, I have tried everything. <form id="filter"> <?php ...
2 votes
2 answers
1k views

How To Change The Html of Products filtration sidebar in Woocommerce?

I have Used the function dynamic_sidebar('sidebarId') in the sidebar.php file. and all the functionality of the sidebar is Working succsessfully My Question is How To Change the Html of the sidebar ...
0 votes
0 answers
12 views

(plesk)After adding 1000 youtube url to my 1000 different wordpress article, my all websites doesnt show yt url as embed

i added 1000 article with 1000 youtube url, i directly pasted youtube url, but after that, including that site, my all sites on my dedicated hosting doesnt show the youtube embed after i paste direct ...
0 votes
0 answers
10 views

Output categories as seperate list items instead of one paragraph [closed]

I have some code snippets provided by a plugin author as part of documentation to customise the plugin. It adds the ability to display categories on a store listing: add_filter( 'wpsl_store_meta', '...
0 votes
2 answers
804 views

Remove generated category and tag class names from woocommerce product & blog listings markup

I noticed in my wordpress/woocommerce setup that every time i add a tag to a product or a blog post. It adds that tag as a class into the listed item (Product/blog) I also noticed it adds a class in ...
0 votes
2 answers
5k views

loading a php file to a specific page id

I'm trying to assign a php file to a specfic page? I have modals stored in different files and want have them load in when their assigned page is called. These pages are using the same theme, "...
0 votes
0 answers
18 views

Replace attribute terms with wp_update_term (woocommerce)

On the edit.php?post_type=product&page=product_attributes page I want to replace (when I import a product via my importer plugin) the term name of the Terms attribute with a new name. For example:...
0 votes
2 answers
2k views

How to disable register and reset the password from WordPress admin panel?

How to disable register and reset the password from WordPress admin panel? Please I want to do this by codes without using plugins.
1 vote
2 answers
2k views

You do not have sufficient permissions to access this page while making a plugin

You do not have sufficient permissions to access this page. This is the error i am facing while making my own plugin.Actually, i want to link to another page. Wordpress version is 3.8.1 I made a ...
1 vote
1 answer
4k views

Pass php dynamic variable to shortcode

I am not sure if there is a simple solution to my problem. The requirement looks simple but unable to find answer even after breaking my head for 6 hours. I have to pass variable from a php function ...
0 votes
1 answer
1k views

Path for contact form file

I have a php contact form that I use with all websites, so ideally I want to avoid using a plug in. The files used include: • contact.php - A file with php/html write up which displays the form ...
0 votes
2 answers
1k views

How do I output user_registered time in my correct timezone?

I am currently using Wordpress, and an element of user_registered returns the time of registration of the user. I have set the correct timezone, but don't know how to get the user_registered output to ...
0 votes
2 answers
33 views

Import Wordpress header / footer into an external page(s)

I have an external forum application, which has an option to include a header and footer as HTML. In theory I could use HTML to create the header, but this would be very hard to keep up to date, even ...
1 vote
1 answer
9k views

subdirectory index.php is not working

I have setup wordpress in the root directory and at the same level I have some other directories e.g named "sq". Under sq there are subdirectories like first, second, ... under each subdirectory ...
0 votes
0 answers
8 views

How to add icon to WooCommerce add to cart button

in woocommerce, I want to add an icon from the iconify library to the add to cart button of my site I made some attempts, but I did not get the desired result. I used WooCommerce hooks, but this icon ...
2 votes
1 answer
1k views

Seo Friendly Filter URLs

Is it possible to create more SEO friendly filter URLS? Instead of: https://example.com/product-category/rings/?filter_material=gold Then: https://example.com/product-category/rings/rings-in-gold/ ?
0 votes
1 answer
711 views

How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?

I would like to add toggle style button near the left sidebar for collapsing and opening/closing the left sidebar of Wordpress default Twenty Fifteen theme. I have this code for only removing the ...
0 votes
0 answers
12 views

How do I see logs of critical errors of specific pages without enabling public debug for everyone?

I have a site that works well in production, say with N pages currenly being used by users. I am doing some PHP scripting in one specific page and I want to debug some data. Usually in projects not ...
0 votes
0 answers
8 views

How to fetch WordPress Gallery Images to a Custom Post Type?

I am using the WordPress Email Contact Form plugin to create a custom contact form. I want to be able to fetch images from the WordPress gallery and display them in the contact form. I have tried ...
0 votes
1 answer
2k views

How to solve 404 permalink errors on nginx server

I can't solve this issue. I tried everything I found over the web. I first tried configuring my nginx.conf following the example on codex with no success. https://codex.wordpress.org/Nginx I found ...
1 vote
2 answers
10k views

AJAX success response is not working but it's saving my changes

I'm a beginner in jQuery-Ajax so please bear with me. My Ajax response does not seem to load but my changes are being saved. but gives me this error on admin-ajax.php "call_user_func() expects ...
0 votes
0 answers
22 views

How prevent STDOUT of Plugin_Upgrader->upgrade(...)?

🖥️ Code function my_custom_endpoint(WP_REST_Request $request) { $plugin_file = $request->get_param("plugin_file"); if(!class_exists('Plugin_Upgrader')) { require_once ABSPATH ....
0 votes
1 answer
976 views

How to override theme's public static function inside of a trait?

I use a theme which has a public static function to display a part of a page like: trait SomeTrait { public static function some_function() { ?> <div class="some_class">Some ...
0 votes
2 answers
792 views

Display featured image of post type category

I inherited a website that had a significant number of customized PHP files. I have removed many since, however, this is one of the few that still seemed relevant. The code below displays 1 image at ...
0 votes
1 answer
28 views

WP_Error Object in wp_remote_post & wp_remote_get

I am using localhost and working on a wordpress plugin, I try to get and post data with wp_remote_get and wp_remote_post,i installed lmfwc and i create a rest-api-key, as you can see i used consumer ...
1 vote
2 answers
4k views

Upload file could not be moved to wp-content/uploads

I know it has been asked over and over again on the internet and i spend hours digging deeper into the web. But the no answer so far. Why we get this error when you upload a file The uploaded file ...
0 votes
1 answer
1k views

Use AJAX to fetch Current Post Thumbnail for Wordpress when Uploaded throughMedia Uploader Frontend

i Use WordPress Media Uploader on Frontend to allow users to upload Thumbnail for there UGC site. I also show a Preview of the Image on Frontend. When a user clicks the button the Media Uploader opens ...
0 votes
1 answer
69 views

Add/Modify rel=canonical of all the pages of a wordpress website

Some background to the situation: We're currently running two exact wordpress websites at two different domains, xfilpak.com and xfilpak.ca. We want to make xfilpak.ca the canonical website. ...
0 votes
2 answers
1k views

How can I enqueue comment-reply script only on certain page?

I'm trying to enqueue comment-reply.js script only on a certain page but something is wrong with my code. Can someone hint things here? <?php if ( is_singular('1740') && (!is_home() || !...
1 vote
1 answer
3k views

prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site

I have seen a number of methods dating back to about 2011 in order to take a form and have its data posted via ajax.jquery. I have tried a couple and am just getting the page to reload despite using ...
0 votes
1 answer
20 views

how to test for options(fields) in settings API?

I've created an options page in wordpress with this code: <?php add_action( 'admin_menu', 'rtwhc_add_admin_menu' ); add_action( 'admin_init', 'rtwhc_settings_init' ); function rtwhc_add_admin_menu(...
0 votes
0 answers
19 views

Execute a PHP Function when a Block is used and access it's attributes

I've just build my first block using the @wordpress/create-block package. Everything is working as expected however I need to access the attributes on save and place a script containing a JSON schema ...
-1 votes
1 answer
21 views

Custom rest fields not loaded in rest api cpt response

I have a custom endpoint that will be used from my vue app to load custom post type I've registered using a custom plugin. I need to add some custom fields to the response when the posts are loaded ...
0 votes
1 answer
6k views

admin-ajax.php 400 bad request - whats wrong with my code?

I'm getting a 400 bad request from admin-ajax.php & warnings from pagespeed insights tell me it's an issue. Can you see any obvious issues in the code in our admin-ajax.php file? <?php /** * ...
0 votes
1 answer
667 views

Executing php on button press

I would like to create a button, which will execute the php code when pressed. The issue here is the construction like this does not work: <?php if($_SERVER['REQUEST_METHOD'] == "POST"...
0 votes
1 answer
26 views

add_action() not working for admin

Making my own custom plugin and using add_action several times without a problem with one exception. Currently function below are located in functions.php in the appropriate themes folder. function ...
0 votes
2 answers
635 views

Add wp posts to cutom masonry grid

I need to create masonry grid containing the latest posts. I created a grid based on https://masonry.desandro.com/ - the grid displays correctly. I am asking for help in creating a wp loop that will ...
1 vote
1 answer
964 views

How create a Shortcode with hover and complex options

I am wondering how do you do when you have to create a shortcode with multiple hover or complex options ( gradient, boxshadow etc, thing that can't be inline ). How do you generate the css. I don't ...
0 votes
1 answer
860 views

How to get php file based on URL in WordPress

I am trying to edit the home page for the wordpress site but I am not able to find the PHP file. The file should be under the theme file and I have checked almost all the file(which is not the correct ...

1
2 3 4 5
209