Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

5
votes
0answers
53 views

PHP code in page template vs functions

I've made numerous WordPress sites, and learned PHP practices that I believe to be right, i.e. functions go in functions.php file, nearly everything in functions.php should be wrapped in a function, ...
5
votes
0answers
259 views

static variable loop not working in Wordpress

I have a function in my wordpress theme that deletes the first embedded video in a video post. See code below. This is in the functions.php file. /* - function that hides first video in post content -...
3
votes
0answers
219 views

WordPress “Link has expired” error on updating posts

I'm maintaining a WordPress site on GoDaddy for a client and they started to get the "this link has expired error" when they saved a post. It does not happen when I upload a file. However, I am ...
3
votes
0answers
25 views

Get widget settings function?

I am using this to find if a new widget has been added or removed from my site: serialize(retrieve_widgets()); Works great for added or removed widgets. But it doesn't detect if a widget setting has ...
3
votes
0answers
2k views

admin-ajax.php returning error 400 namespaced callback

I'm writing a plugin and I'm getting an error 400 Bad Request from admin-ajax.php. I did some poking around in the Wordpress core about this and it seems where it's getting hung up is around line 85 ...
3
votes
0answers
280 views

Setting Up PHPUnit tests for WP development on Windows

I've been following the instructions in this article to try to set up some testing. I got as far as this instruction bash bin/install-wp-tests.sh wordpress_test root 'mypass' localhost latest before ...
3
votes
0answers
263 views

Order Wordpress Custom Taxonomy Pages & Pagination Not Working

I'm using this code to enable custom post types and taxonomies on my site (I've also included this below to save linking out) https://gist.github.com/kasparsd/2924900 The code works great for the ...
3
votes
0answers
171 views

allow arabic letters when register new account

How can allow arabic letters when register new account ? i don't need to lose any security. If any of us, Arabs, want to register in any wordpress blogs we have to use English letters in “username” ...
3
votes
0answers
76 views

my function doesn't return my post from today

I'm using gravity form to create some custom post type - as events. Everything is working great, There is some date field to setup the event from x to y date. ALl of this working great. However, I ...
3
votes
0answers
121 views

wp_handle_upload_prefilter valid date from input file

I want to ask some help, i'm having problem with thewp_handle_upload_prefilter Here is the code: add_filter('wp_handle_upload_prefilter','mdu_validate_image_size'); function mdu_validate_image_size( $...
3
votes
0answers
166 views

Dynamically add styles to WP TinyMCE editor

I want to add custom styles to Wordpress using dynamic arrays. My question is how can I add the two arrays to the style_formats array within the 'my_mce_before_init_insert_formats' function ...
3
votes
0answers
583 views

Making a follow button, Ajax not talking to php

I'm trying to make a user follow button using AJAX, but for some reason my AJAX isn't talking to my jk_user_follow function and setting the wp_set_object_terms. PHP function register_user_taxonomy(){...
3
votes
0answers
1k views

Unique key for each row in a repeater field

Is it possible to have a unique key for each sub fields in a repeater field? I don't want to use the array index, because the array index can be changed, when adding new rows between existing rows. I ...
2
votes
0answers
47 views

How to return output of the new wp gallery block for automatically Link images To Media file

Sorry for the repeated questions but I didn't get any solution yet! I'm stuck with that!! I mange a multi writers blog, and all our users uploading some gallery images, and they didn't know the ...
2
votes
0answers
53 views

Display notification only once

I am trying to use the getItem and setItem method to display notifications in an array only once. It works for the first 5 notifications but once you go above 5 there are a few issues that arise. For ...
2
votes
0answers
621 views

How to find cause of PHP notices with no stack trace?

My WordPress debug.log is filling up with this group of seven PHP warnings/notices, recurring at least every half an hour... [08-Mar-2018 09:05:03 UTC] PHP Notice: Trying to get property of non-...
2
votes
0answers
1k views

WooCommerce: update custom fields after checkout validation failure

In my project I'm customizing some of the WooCommerce features. My "shipping methods" are: 1. delivery 2. take away I also added a custom field in the checkout page that is a <select> populated ...
2
votes
0answers
233 views

Custom post type editor with dynamic selects, one drop down populating a second second drop down not working

I have a custom post type where I am attempting to have one select populate the options of a second select in the custom post type's editor. The first drop down pulls in a list of tags associated to ...
2
votes
0answers
3k views

Add attribute / custom attribute to product in woocommerce

I have products from some API and want to insert these products. I was able to insert products and use already existing attributes ( or added by UI ). Adding new term (My Color) to the existing ...
2
votes
0answers
150 views

Programmatically create menu with custom link

I am creating pages and assign them to a menu with custom link. Pages are properly created and menu is properly created, too. However, custom links are not given to the menu items. What I want is to ...
2
votes
0answers
46 views

How to iterate through database until it find a match

How can I loop through my Wordpress query, and check each posts if one meta_value of meta_key user_ip_reservering match the $ipadres Code $args = array( 'post_type' => 'reserveringen', )...
2
votes
0answers
40 views

Assign External Database Queries to Global Variables and Make Them Accessible

I've got a bit of a tough question involving a website and its web app counterpart. The Background The website relies on two different databases: its default, named wp_website, and its counterpart's ...
2
votes
0answers
327 views

WP All Import - Execute Imports

After I completed my CODE and finished my site, I now have another problem. I use a plugin called WP All Import to import my products. I want that the different imports are executed by WP All Import ...
2
votes
0answers
77 views

I am having a problem with form updating/editing Wordpress post on the frontend

I am having a bt of a problem trying to allow users to edit their own posts (custom post type) on the front end. the form is being displayed and errors are displayed but the form is not updating the ...
2
votes
0answers
53 views

allow users to publish without admin approval

i have a website for ads, when a user want to add an ad he have to login then added his ad from frontend, but this ad will need an admin approval, i want to add an option to my theme that allow my ...
2
votes
0answers
32 views

How to filter out post type meta?

I have used this code to filter out the post type and it works fine when showing filtered results: add_filter('wpseo_title', 'vehicle_listing_title'); function vehicle_listing_title( $title ) { ...
2
votes
0answers
394 views

Trigger Woocommerce New User Email

I wrote a custom plugin that handles login and registration for my WordPress Woocommerce site. When a user registers via my custom form handler I would like to trigger Woocommerce to send the new ...
2
votes
0answers
179 views

Use WordPress's Media Uploader/ Manager in non WordPress php application

I need a image upload and browse, resize, crop functionalities. Since it is already built available in wp. I need some idea how can i use it my custom php application Laravel. Adding the media ...
2
votes
0answers
62 views

Can I check plugins and themes for PHP 5.6 ahead of global PHP server Update

My server is updating to PHP 5.6 next week. I manage about 30 WordPress websites. I looked for a plugin that would check if any of the code throughout the other plugins and theme would break with the ...
2
votes
0answers
651 views

Passing jQuery value using Ajax to a page template

I have the following jQuery code:- jQuery('.fancymember').on('click', function() { var member = jQuery(this).parent('div').parent('div').find('.test').val(); var dataString = 'member='+ ...
2
votes
0answers
749 views

bulk change of image setting “link to” to “link to: image url ”

i want every image present on my wordpress site with setting "link to: none" or "link to: post url" became in "link to :image url" ho make this for old post and for new post ? i tried this code in ...
2
votes
0answers
660 views

Custom Loop through category menu to include sub categories

In my custom wordpress theme I currently have the below loop to the main categories <?php $menu = wp_get_nav_menu_object('navigation'); $items = wp_get_nav_menu_items($menu->term_id); foreach($...
2
votes
0answers
2k views

How to resize image on client-side before upload?

I've been using Plupload to resize images on the client side before uploading them to the server. I've implemented a front-end form which lets the user select a file from their computer and submit it. ...
2
votes
0answers
1k views

Getting Post Thumbnail from RSS feed with SimplePie

I am trying to pull the post thumbnail from an RSS feed to output on an external site. I am using the following function to add the post thumbnail to the site: function rss_post_thumbnail($content) { ...
2
votes
0answers
2k views

How to set a custom path, for ajax image upload folder in admin?

I am coding my first Wordpress plugin that handles some data for a custom (shop-like) post type. It also has an image uploader within a metabox, where you simply drag in your images and it ...
2
votes
0answers
710 views

Adding dropdowns to the tinyMCE editor

I'm new to php and wordpress but I've managed to figure out both pretty easily thanks to the community, forums and blogs. I'm close to figuring out what i want to do here, but wasted hours without ...
2
votes
0answers
189 views

Passing the page ID to a login php script

I'm trying to create a simple registration process which goes like this, A visitor clicks on a link (which is viewable only after entering some information such as name, email, phone etc.) This link ...
1
vote
0answers
12 views

Wordpress can't find temporary folder, but folder it's looking at has correct permissions

So, I've spent a couple of hours looking around the internet to try to figure out this problem, since it seems like a dumb one that would probably be a duplicate, but apparently it isn't. I'm hosting ...
1
vote
0answers
28 views

Image rotation and editing stopped working in Wordpress after upgrading Ubuntu from 16.04 to 18.04

I'm seeing this error in Wordpress Media editor: "Image rotation is not supported by your web host." I checked on my server and I have php7-gd: php -i | grep -i gd /etc/php/7.2/cli/conf.d/20-gd....
1
vote
0answers
22 views

user_profile_update_errors hook not executing

I'm trying to use the user_profile_update_errors hook, however it doesn't appear to be executing. I'm calling it like this: add_action('user_profile_update_errors', 'blm_register_result', 10, 3); ...
1
vote
0answers
28 views

Can an array be used as a meta_query value?

I'm trying to query a custom post type (courses) by grade using WP_Query and Advanced Custom Fields (ACF). Grades (checkboxes) are organized by term (groups). Four grades per term, four terms per ...
1
vote
0answers
125 views

Basic Object Oriented plugin question

I'm looking to create a plugin that displays a custom posts label for posts that belong to selected categories. And since I'm new to OOP, I'm struggling to understand whether to use arrays instead of ...
1
vote
0answers
117 views

Error on wp_default_style After upgrade to php 7

After upgrading my site to php 7. I have been constantly getting this error regarging the parameter to native wordpress function wp_default_style(). Spent so many days to fix it but was not able to ...
1
vote
0answers
26 views

Limit Widgets to Sidebar ID's

First, my English is not good, sorry about that. I have widgets. I want to limit them by sidebars ID's. I did that but it's working only moving widget left to sidebar areas. But when I reload page, (...
1
vote
0answers
322 views

WooCommerce: How can I get orders with a custom ID in order meta data object?

Because of a project I need help from you. I've searched a lot but I can't find a solution. I'm trying to edit a WooCommerce function named woocommerce_account_orders I've added the field ...
1
vote
0answers
37 views

How to add an arrow to menu items has submenus

I want to add arrow (or anything like ...) after every menu item that have children menus. I know that there is some JavaScript solutions. But for some reasons (stability and ...), I don't want to ...
1
vote
0answers
14 views

How to improve my Wordpress filter to include empty custom fields

I have a custom columns of suppliers and I want to create a filter in which I could filter my products based on empty fields as well. I have the following: add_filter( 'parse_query', '...
1
vote
0answers
21 views

How to edit content before post update

I'm creating a plugin that enables the user to highlight certain words (long words, long sentences etc.) in the TinyMCE Editor. You can see a live version here: https://tekstr.dk/app I'm converting ...
1
vote
0answers
32 views

Which hook/action will help me solve my problem?

I want to add my first post of current date to drafts and when the second post is added, I want both of them to be published together. Below is my code and I am confused on how to post them in draft ...
1
vote
0answers
13 views

How to change the oembed “type”?

By default the oEmbed type of my wordpress posts is "rich", but I want to convert it to "Video". I spent 2+ hours trying to find the answer but with no luck, is it possible?