How to Insert Shortcodes into Theme?

You can hardcode shortcodes into a theme using do_shortcode. http://codex.wordpress.org/Function_Reference/do_shortcode echo do_shortcode(‘[wp-like-locker] Your locked content here… [/wp-like-locker]’); You will most likely want to replace the hard-coded “Your locked content here…” with the function that pulls the content from the editor, like the_content http://codex.wordpress.org/Function_Reference/the_content It might look like // the loop $content = get_the_content(); echo do_shortcode(‘[wp-like-locker]’ … Read more

LESS compiler for WordPress

Alternative see the lessphp Project: https://github.com/leafo/lessphp Works fine and hase an team of contributor. But has not an out of the box function for WordPress; but uts only PHP and the WP has the right Hooks. Do you will only use in themes, then its also fine, that you include this and it works with … Read more

WordPress – query 5 posts with a specific post in top

You can do this by using get_adjacent_post() and the filter get_previous_post_where or get_next_post_where. You’ll call get_adjacent_post() as normal, but you’ll need to change the LIMIT to 5, using the filter. I wasn’t sure from the question whether or not you wanted to have the current post be first. If you do, you’ll need to set … Read more

Validate emails in array using foreach

Are you aware you can pass a comma-separated string of email adresses to wp_mail? // Make sure your email strings only uses comma as a separator $emails = preg_replace(‘~[,;\s]+~’, ‘,’, $emails); Then just throw that string into wp_mail’s first argument. Depending on exactly what you want to do with the emails, this approach may be … Read more

Add custom php database code above

You could use a WordPress action hook. For example, you could add the following code to your themes functions.php file: add_action( ‘init’, ‘your_script_function’ ); function your_script_function() { // your script here } The first line makes WordPress execute the ‘your_script_function’ function on initialization. You can add your script in that function. Alternatively, you could add … Read more

Changing the template hierarchy

Try this filter function wpse_63614_restructure_template_hierarchy( $template ){ return get_template_directory().’/filename.php’; } add_filter( ‘template_include’, ‘wpse_63614_restructure_template_hierarchy’ ); The filename would be the file you would want to call in your theme folder. For child themes you would use get_stylesheet_directory instead. EDIT: Or as suggested by Chip Bennett and what I too feel would be better; you can use … Read more