How to search display_name column when using WP_User_Query

You can try this: /** * Add support for the “display_name” search column in WP_User_Query * * @see http://wordpress.stackexchange.com/a/166369/26350 */ add_filter( ‘user_search_columns’, function( $search_columns ) { $search_columns[] = ‘display_name’; return $search_columns; } ); where we use the user_search_columns filter to modify the available search columns. So what fields can we use with this filter? Here’s … Read more

Sorting list of sites from multisite network using wp_get_sites

Using get_sites() in WP 4.6+ It looks like wp_get_sites() will be deprecated in WP 4.6. The new replacement is: function get_sites( $args = array() ) { $query = new WP_Site_Query(); return $query->query( $args ); } Very similar to get_posts() and WP_Query. It supports various useful parameters and filters. Here’s what the inline documentation says about … Read more

Receiving Stripe Webhooks on a wordpress website

I recently had the same problem and pippins stripe integration plugin seemed to answer it but it had a lot of extra code I did not need so I removed it and made a concise version just for the webhook integration: WPStripeWebhook. README is self explanatory. Basically make changes to includes/stripe_listener.php for your events. Also … Read more

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

This is what you need, taken from – https://stackoverflow.com/questions/27087772/how-can-i-change-meta-alt-and-title-in-catalog-thumbnail-product-thumbnail add_filter(‘wp_get_attachment_image_attributes’, ‘change_attachement_image_attributes’, 20, 2); function change_attachement_image_attributes( $attr, $attachment ){ // Get post parent $parent = get_post_field( ‘post_parent’, $attachment); // Get post type to check if it’s product $type = get_post_field( ‘post_type’, $parent); if( $type != ‘product’ ){ return $attr; } /// Get title $title = get_post_field( … Read more

Remove option to allow trackbacks/pingbacks from post page options

Your code is correct, AFAIK. It will disable the ability to do trackback/pings. It doesn’t remove that option from the screen, as you have noticed. Not sure how to test that, though. But your code should work to disable the actual process of allowing trackback/ping. This site might test trackback/pings https://tech.wizbangblog.com/ping.php . No experience with … Read more

How to call a PHP function from Javascript in WordPress

Here’s an example: Use this sample JavaScript code: jQuery(document).on(‘click’, ‘.some-element’, function(e){ var ipc = jQuery(this).data(‘collection-id’); jQuery(‘.some-other-element’).show(); jQuery.ajax({ method: ‘post’, url: ipAjaxVar.ajaxurl, data: { collection_id: ipc, action: ‘my_function’, } }).done(function(msg) { // Do something when done }); e.preventDefault(); }); PHP (include the function in your plugin, do not use a separate file): // Include the JavaScript … Read more

WSOD but WP_DEBUG not giving any errors

Make things simpler by using this in wp-config.php: define( ‘WP_DEBUG’, true ); /** debug on */ define( ‘WP_DEBUG_LOG’, true ); /** log enabled */ define( ‘WP_DEBUG_DISPLAY’, true); /** display enabled */ The @ini_set(‘display_errors’, 0); may be breaking the WP_DEBUG error display and logging by calling the native PHP error reporting at the same time.

How display widget by id

You can use wp_get_sidebars_widgets() with an “on demand” filter callback. This means we’re adding the filter callback, right before the call to the function and then remove right inside the callback again. This allows us, to use it only once. It also means, that we need to set it right before the call to wp_get_sidebars_widgets() … Read more

Check if post of title already exists

Yes $wpdb is built in and is loaded by the WordPress Core on every page load. I don’t see any critical problem with your code. I am going to suggest some improvements because I see some places where could go wrong, but mostly that should work. That makes me think that $article->heading is not matching … Read more

Is having multiple theme customizers for different pages possible?

This is not a complete solution and the code is not tested, but I it should be enough to give you a general idea of how to use the customizer for different pages. // Add “Edit page with customizer” link to relevant pages add_action(‘admin_bar_menu’, function($bar) { if (is_home()) { $bar->add_node(array( ‘id’ => ‘some-id-1’, ‘title’ => … Read more