Tag Info

Hot answers tagged

4

WP doesn't "look" at the type of data you have, it just has a default of CHAR. So if you dump your current query you will see respective type cast: CAST(wp_postmeta.meta_value AS CHAR). To make it work you need to specify type argument explicitly 'type' => 'NUMERIC' and CAST will change accordingly: CAST(wp_postmeta.meta_value AS SIGNED). See Custom ...


2

Plugins are loaded before the theme which means that your apply_filters won't have any actual callbacks registered to it. Instead, you need to call your apply_filters sometime after the theme has been loaded. Something like this: /* Your plugin's file: */ add_action( 'init', 'my_lovely_funky_filters' ); function my_lovely_funky_filters() { /* Fire our ...


2

With the lastest version of WordPress (4.3) you can now natively remove the customizer's theme switch setting without resorting to CSS hacks. /** * Remove customizer options. * * @since 1.0.0 * @param object $wp_customize */ function ja_remove_customizer_options( $wp_customize ) { //$wp_customize->remove_section( 'static_front_page' ); ...


2

Add another preg_replace. Something like: $text = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', "", $text);


2

Like this: function custom_js_to_head() { ?> <script> jQuery(function(){ jQuery("body.post-type-YOUR-CUSTOM-POST-TYPE .wrap h1").append('<a href="index.php?param=your-action" class="page-title-action">Import from ...</a>'); }); </script> <?php } add_action('admin_head', 'custom_js_to_head'); ...


2

You will want to use the post_row_actions filter https://developer.wordpress.org/reference/hooks/post_row_actions-2/ For example, to add a link, you could try something like: function add_custom_link($actions, $page_object) { $actions['custom_link'] = '<a href="http://www.example.com">My Custom Link</a>'; return $actions; } ...


1

You want the has_action() function. add_action( 'category_promo_header', function () { echo 'hi there'; } ); if (has_action('category_promo_header')) { echo '<div>'; do_action('category_promo_header'); echo '</div>'; } Comment that add_action and you should see that nothing is printed at all.


1

Just small nuggets of information that may help in simple setups (most notably the ones with no use plugins using ob_start): 1) You don't need the to put dns-prefetch calls as the first elements. What you need is to put them as soon as possible before any other element calling external resources. 2) Is actually possible to use negative numbers as priority ...


1

The earliest safe hook to get post information is the template_redirect hook. All the hooks in question runs before Wordpress has setup postdata, so any post info are still unavailable at that point. The globals like $wp_query and $post will still contain no data, that is why your efforts returns nothing. EDIT Extra info as per comment by @TheDeadMedic ...


1

No, you cannot do that, unfortunately, because get_header( $name ) doesn't have a filter for the $name (it only passes the name with the action call). However, if you are willing to modify the header.php file for each site with something like this right at the beginning of the file: <?php if ( apply_filters( 'load_custom_header', false ) ) { ...


1

Have you seen this ? http://stackoverflow.com/a/28429009/3967385 Actually you can't fire JavaScript with php simply like that.


1

There's an array option when creating a custom post type and custom taxonomy for ""rewrite"" and you can set a ""slug"" and it's there that you can change your permalink structure. For more read here. Also the other option that I get from post 1 and post 2 one helped me blink some idea. 1 Rewrite rule: You need to add a new rewrite rule so Wordpress knows ...


1

(I was going to add this as a comment as it's not a full answer, but I can't yet...) I think you will need to use an SQL query as the standard meta_queries / orderby won't work. Have a look at Custom Table Column Sortable by Taxonomy Query and http://wpdreamer.com/2014/04/how-to-make-your-wordpress-admin-columns-sortable/#sorting-posts-option-b for a couple ...



Only top voted, non community-wiki answers of a minimum length are eligible