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]

The server-side programming language that the WordPress core, plugins and themes are written in.

5
votes
0answers
236 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 -...
4
votes
0answers
37 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, ...
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
233 views

TechCrunch WP Asynchronous Tasks plugin still works on v4.7.5?

Does anyone know if the TechCrunch WP Asynchronous Tasks plugin still works on Wordpress v4.7.5? Plugin: https://github.com/techcrunch/wp-async-task I'm trying to get the action hook working ...
3
votes
0answers
252 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
246 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
165 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
113 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
158 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
210 views

category_name not working (not showing up in sql query debug)

My plugin has a shortcode and it retrieves animals. There are filters/arguments and they all work well except the category argument or parameter. The category name(s) is/are well passed to my ...
3
votes
0answers
572 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
117 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 ...
2
votes
0answers
48 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
151 views

How To add custom radio boxes to WooCommerce Billing page and change total price by this field?

Lets say i need to add custom radio fields ( company or person ) at the top of the form to the billing for. And if the visitor checks person they should pay 21% Tax and they select company that is ...
2
votes
0answers
220 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
2k 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
142 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
39 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
306 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
73 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
371 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
174 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
640 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
681 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
643 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
705 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
18 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
22 views

Access Wordpress data from external PHP application.

I am a volunteer in a non-profit organization. I have taken over maintenance of a number of apps written in PHP/SQL/Dreamweaver. The apps are over 10 years old. I am migrating these apps from PHP/SQL ...
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
49 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
22 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
31 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
17 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?
1
vote
0answers
352 views

How do I configure WordPress to talk to a Microsoft SQL Server database?

We have are building a WordPress site on our intranet site and wish to connect it to a Microsoft SQL Server. I have downloaded and configured PHP and PHP Manager on IIS. I have also downloaded SQL ...
1
vote
0answers
16 views

WordPress Gravatar filter is removing my custom attributes

I am trying to add a style attribute on all the custom gravatar images. However, it is removing the style attribute before final output. Here is the code I am using: $background = ''; $args = [$...
1
vote
0answers
33 views

Script to browser problem PHP

this is what I want to do Output here (A - FB and None FB): John facebook Mary facebook Peter ? Nicolas facebook Camilla ? Peter ? Sam ? Jacko ? Ola facebook Erick facebook And here (...