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

Displaying a WooCommerce product via PHP

Use do_shortcode(). For example, in a template, if you were wanting to display products specifically by ID: <?php echo do_shortcode(‘[products ids=”1, 2, 3, 4, 5″]’); ?> WooCommerce comes with several shortcodes which can be used to insert content inside posts and pages: http://docs.woothemes.com/document/woocommerce-shortcodes/ You can add shortcodes to a post or page easily via the … Read more

wpdb::prepare was called incorrectly

It’s always advised to use $wpdb->prepare when you are taking input from user. This will help in protecting queries against SQL Injection. For more details, check the Codex When you use $wpdb->prepare, you must pass the variables to the query. In your case, you can skip using $wpdb->prepare as you are using a hard coded … Read more

the_author_meta() vs get_the_author_meta()

If you look at the source code for the_author_meta(), it simply, in essence, just echo’s the result from get_the_author_meta(). WordPress has quite a lot of functions where functions with a the_* prefix simply echos the results from its get_* counter parts. The get_* prefix is almost always used for functions which return its results. There … Read more

exclude multiple terms using get_terms() function

With get_terms(), the exclude parameter takes an array of term IDs, so just add the second term to the array: $terms = get_terms( TribeEvents::TAXONOMY, array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘exclude’ => array( 77, 71 ), ) ); echo ‘<li>Category:</li>’; foreach ( $terms as $term ) { echo ‘<li><a href=”‘.$url.’?tribe_eventcategory=’.$term->term_taxonomy_id.'”>’.$term->name.'</a></li>’; }