The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
2answers
13 views

Add code to the header of posts by particular author

I want to add CSS code to the header of all the posts by a particular author. I tried the following solution: function hide_author_box() { if (is_author('ritesh')) { ?> <style> ....
-1
votes
0answers
10 views

Add WooCommerce product attributes + translation in WPML

I have followed this approach: https://stackoverflow.com/questions/47518333/create-programmatically-a-variable-product-and-two-new-attributes-in-woocommerce/47844054#47844054 to programmtically ...
-1
votes
0answers
17 views

How to save $_POST['acf']['field_X'] data from a custom form?

I have a User Submitted Posts form in which I've included my ACF field group. $_POST['acf']... includes data submitted via form and with USP filters I can hook into newly created post/article which ...
1
vote
0answers
26 views

Issues getting PHP to display in category pages

I am using this code to display social media share links at the top of my posts. Currently, they display fine on my pages and posts. Is there any way to get this to display also on my category pages? ...
0
votes
0answers
12 views

Custom TinyMCE buttons not loaded in html mode

I'm trying to add multiple shortcode custom buttons to the TinyMCE wordpress editor. I have writed this code and it's working fine but the buttons are loaded only on the visual editor mode, Is it ...
0
votes
0answers
9 views

Use font-awesome for TinyMCE icons

I've found a solution to add my custom shortcodes to the wordpress TinyMCE editor. I don't have custom icons for the shortcodes ao I'm thinking to use font-awesome. Is possible to set them inside the ...
0
votes
0answers
38 views

How To Toggle User_Meta in frontend in a form using PHP

I am trying to make a small form, that just has a submit button, and on submission, it should toggle user meta for the WordPress user. The button exists on frontend after content of post, and has a ...
0
votes
1answer
12 views

Display page content in different sections - based on page break block?

Is there a way to loop through page content, and display the content that is above page break in one section, and everything that is below the page break in another? Or additionally, a way to generate ...
0
votes
2answers
19 views

Running a PHP SQL script on a wordpress page

This is a very basic question. I am using Serverpress for local development.I have been trying to create a dynamic dropdown.I did some reading and I found an example html,php and jquery script that ...
0
votes
0answers
11 views

Woocommerce Multiple prices per product based on City

The problem I am facing is that I need to implement multiple prices per product based on city selection. The website is using Wordpress and Woocommerce. I need each product to have a different price ...
0
votes
0answers
15 views

Add a WooCommerce Product Variant with attributes programmatically

I am creating a custom import script (say from a CRM system) and I need to create products and product variations. I have been unable to find any recent snippets about how to do this in the most ...
0
votes
1answer
39 views

After adding my website to a new server, I keep getting a unexpected end of file error, but the file is identitcal to it's original source

I have this script that changes buddypress' cover image template. this file works fine on my server, but as soon as I moved it to my client's server, it broke. I keep getting the error Parse error: ...
0
votes
1answer
16 views

How to access or parse key/values that have “string”

Coming from a Perl background (no snickering) and trying to make sense of some new conventions. Not sure whether this is a PHP, WordPress, or Ninja forms question. $form_data //Ninja parlance ...
0
votes
1answer
19 views

How to bind each “the_content” elements to a custom variables

I'm implementing bootstrap theme into wordpress and i need you'r help. In Wordpress i created a simple page with paragraph and a list of 3 item's. Product list one Product one - Link Product two - ...
0
votes
1answer
12 views

WP Error using wp_insert_term

I have attached my code below. This code previously worked, but has since stopped. I can't understand why the error code is throwing now. I've marked where the error is occuring using // * ISSUE IS ...
0
votes
1answer
19 views

If Array Values Match Another Array's Values, Then

I have a user drop-down field that includes High, Medium, or Low ranking. Each ranking has three requirements for evaluation types. I also have three additional drop-downs with options to choose ...
1
vote
1answer
29 views

Shortcode Inside Class Not Working

Working on my first WordPress plugin and using OOP. I'm trying to create a shortcode that works within a class and confused about how to set it up. With my current setup, the shortcode only prints ...
1
vote
0answers
20 views

Ajax date_query not working past the first iteration

I cant find anything on stack overflow that covers my issue, after hours of debugging and checking answers to similar questions but not quite the same scope, I cannot figure out the problem. ...
0
votes
1answer
19 views

Create “blank” admin page without having admin-bar/admin-menu for faster load

I'd like to create a page in the WP Admin backend that is just "white", e.g. without the administration menu or the admin bar. I am NOT looking to create an admin page without adding it to the menu; ...
0
votes
0answers
25 views

Register/enqueue scripts only on certain admin pages

I found this question here but I'm a bit confused on how to proceed. I need to register or enqueue the bootstrap css for my plugin admin menu page. I've understand that when an admin menu page is ...
0
votes
0answers
14 views

Running a huge background script

I need to handle a import of a lot of rows and database inserts. I currently have the below options: 1) Run on WP backend and let user wait for this. This would require the user to have his browser ...
0
votes
1answer
48 views

Custom Post type slider with thumbnail navigation

I am trying to make a slider for a custom post type with quite a few custom fields. Ive got the query and fields displaying fine. But now to get it into a slider Getting each post in the loop ...
0
votes
1answer
15 views

Trying to reload page with update_option_{$option} hook causing infinite reload

How can I reload the page after this option is updated? What I'm trying below is causing an infinite page reload loop. I've also tried add if($old_value !== $) check but still no luck. add_action( '...
0
votes
0answers
12 views

Post Order with Multiple Queries (ACF)

I created a CPT for "Locations" and I am using the ACF relationship field to pull corresponding staff from my "People" CPT onto each individual location page. Right now, I have them sorting ...
0
votes
0answers
11 views

Pass JavaScript value to PHP [duplicate]

How to step JavaScript value to PHP? The value (passValue) Or the value you have on the "on " or "off " button for here $testup = (passValue); Sorry bad English <button id="toggle" name="...
0
votes
1answer
10 views

post_exists stops working in a scheduled event

I am creating a wordpress plugin that takes an article from one of my wordpress sites and then posts it to different wordpress site. For testing purposes, I want it to pull an article at random and ...
0
votes
0answers
8 views

Load admin menu page from plugin class

I'm learning how to create options pages for my plugin. I have found an interesting article on this argument and I'm trying to do the same. I have a doubt about the implementation inside a class. I ...
0
votes
0answers
19 views

wordpress insert post without actions/hooks

I am developing a custom importer for WordPress (because we have a very custom setup and the available tools don't seem to work for our scenario). During this import, I'd like to disable any hooks ...
0
votes
0answers
10 views

post id or permalink auto-incrementing number and reset everyday

i wanna have a permalinks like this: *.com/2019/10/02/0001 *.com/2019/10/02/0002 *.com/2019/10/02/0003 ... *.com/2019/10/02/nnnn . and the next they the number should be reset to 0001, and ...
0
votes
1answer
22 views

Looping through custom data in a custom table to display all items in a post

Im trying to loop through my custom data in a table to display on the page. Everything is working as intended except the posting to a page using the wp_update_post() function. Here is my function: ...
0
votes
1answer
30 views

How to get the list of WooCommerce product image of a certain category from database?

I am trying to display WC product images (thumbnails) or just get the url to that image from database. But I can't seem to find the column where the url are stored with the following. One thing I want ...
-1
votes
0answers
20 views

Get real-time button value and send to postmeta database

How do I get button value and send to postmeta database? When you click the button. Have to update the file of the plugin testok: WP-content/plugins/testok/file-update-button.php It has a function in ...
0
votes
1answer
57 views

A non-numeric value encountered in /wp-includes/functions.php on line 68

We recently updated our shared hosting to use PHP 7.3 (problem still existed in PHP 7.2 as well) - website is throwing the error in the title. the function in question is: function current_time( $...
0
votes
0answers
20 views

Export Wordpress User Meta to CSV/Excel

I have shops and consultants both set up on Wordpress as users with different roles. I want to include an "Export" link on the consultants' profiles using a shortcode that will export the shops on ...
0
votes
1answer
24 views

The search engine of my website finds only posts and not pages, how can I solve this problem?

I have a curious problem with the Wordpress search engine of my website (the one that makes URLs as http://sitename.com?s=searched+word). When I installed Wordpress I noticed that when I used the ...
0
votes
2answers
16 views

Remove annoying WP Adminbar CSS

I am trying to remove the annoying WP Admin bar css. <style type="text/css" media="screen"> html { margin-top: 32px !important; } * html body { margin-top: 32px !important; } @media screen and (...
0
votes
1answer
19 views

Pagination hitting 404 page on /page/4

This is a bit of a headscratcher. So, I am using the WP Download Manager Pro plugin that creates a custom post type wpdmpro. I have pages for each category, and using the loop, I loop through each ...
-1
votes
0answers
11 views

if else control structure for custom shortcode visualization

I have this code to display two custom shortcodes: The first code block is to display a parallax or a parallax with some content inside, the second one is for a swiper slider. I need to get all the ...
0
votes
1answer
20 views

in_array() says array is a bool?

I'm struggling with an error using in_array(). In the code below I've got $active_modules as the return of a metabox.io function that gets values from an options page. This return value is an array ...
0
votes
0answers
12 views

Get and Update Most Meta Value as an array in HTML form

I'm trying to update post meta for a meta edd_download_files the meta is in the form of an array. It is from a plugin so i can do it via admin, but still there is need to do it programmatically. $...
0
votes
0answers
19 views

Wordpress calling PHP file to do custom logic

We're using the Ninja Form plugin and on submit I have a Webhook that passes all form data as a Json object. What I'm trying to do is pass this data so I can send out an Email of the data in a PDF ...
0
votes
1answer
14 views

register dependency css and js inside a plugin class

I have this code: public function __construct() { add_action('wp_enqueue_script' , array( $this, 'initBootstrap' )); add_action('wp_enqueue_style' , array( $this, 'initBootstrap' )); ...
0
votes
0answers
13 views

Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?

When I delete a record field of WordPress posts database such as Post, Image, Page, etc. and add new item then it will add in a fresh record field due to auto increment function. But I would like to ...
1
vote
1answer
14 views

Add htaccess rules with insert_with_markers at beginning of htaccess

From my custom plugin, on activation, i want add some rules into htaccess but at beginning of the file. insert_with_markers add the rule at the end of htaccess, eg.: $lines = array(); $lines[] = '# ...
0
votes
0answers
17 views

implement get_post_gallery_images() inside a class

As part of my WordPress training I want to make a class method to load swiper.js slider library inside my custom theme using a shortcode. I know how to proceed, but I want to be sure about a little ...
0
votes
0answers
12 views

Date object in the query to show posts from the following month

I'm building a booking for events, each event is divided into taxonomies, this is the query that regulates my custom post type, to display all the posts that are under the "aperitivi" taxonomy. $...
1
vote
1answer
24 views

custom shortcode will not display the wrapped content

I'm trying to create a plugin to have some shortcodes utility for my custom bootstrap 4 layouts. I'm reading the shortcode API docs but I'm unable to display the contents wrapped inside the shortcodes ...
0
votes
1answer
17 views

Wordpress generate images size after upload

I use this code for upload image : function Generate_Featured_Image( $image_url, $post_id ){ $upload_dir = wp_upload_dir(); $image_data = file_get_contents($image_url); $filename = ...
0
votes
0answers
12 views

Exclude specific product tags from related products in WooCommerce 3.7.0

I use the following command line to exclude specific tags products from related WooCommerce products: add_filter( 'woocommerce_get_related_product_tag_terms', 'remove_related_tags1' ); function ...
0
votes
0answers
11 views

PHP site alert - is this code a threat

I host an "unsupported" PHP site for a client. The site appeared to have been "mildly hacked" through the SuperCache plugin which I subsequently updated for them. Unfortunately my AV program has ...