Using WP_Query – how to display something IF there are no results

So, let’s say $query is your WP_Query object. I.e. $query = new WP_Query($some_query_args ); Then you can set up ‘the loop’, by $query->get_posts(); Then to check if there are actually any returned results: if ( $query->have_posts() ) : //Use a While loop to show the results else: //No results, let’s show a message instead. //This … Read more

How to add some custom HTML to the edit posts page

As found here: http://codex.wordpress.org/Function_Reference/add_meta_box /** * Calls the class on the post edit screen */ function call_someClass() { return new someClass(); } if ( is_admin() ) add_action( ‘load-post.php’, ‘call_someClass’ ); /** * The Class */ class someClass { const LANG = ‘some_textdomain’; public function __construct() { add_action( ‘add_meta_boxes’, array( &$this, ‘add_some_meta_box’ ) ); } /** … Read more

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

Only under some circumstances. If the parent theme’s functions are wrapped in function_exists conditionals then you should be able to replace them. For example: // Parent if (!function_exists(‘p_wpse_95799’)) { function p_wpse_95799() { // } } If the child theme defines a function named p_wpse_95799 then the parent function will not be used. If this is … Read more

How to remove hardcoded characters from playlists?

Inside the shortcode function for playlists, there is this line: do_action( ‘wp_playlist_scripts’, $atts[‘type’], $atts[‘style’] ); Hooked into that is wp_playlist_scripts() which hooks the templates into the footer: add_action( ‘wp_footer’, ‘wp_underscore_playlist_templates’, 0 ); add_action( ‘admin_footer’, ‘wp_underscore_playlist_templates’, 0 ); So if you want to replace the templates, you can hook into wp_playlist_scripts after those hooks have been … Read more

Create a global variable for use in all templates

You’ll also have to fill the variable, e.g. function userinfo_global() { global $users_info; $users_info = wp_get_current_user(); } add_action( ‘init’, ‘userinfo_global’ ); And you should then be able to use $users_info everywhere in global context. Keep in mind that some template pars (header.php, footer.php, those used via get_template_part) are not in global scope by default, so … Read more

Shortcode to insert

Best solution for what you want to accomplish which is essentially to make the next page feature more user friendly for your authors is to add a TinyMCE button that will do this for you. This may be a bit complicated so hold your hat. To avoid this answer being the length of a thesis, … Read more