Sort Posts Best Practice

The function add_query_arg adds or replaces ‘GET’ parameters in a given (or the current) url. For instance, suppose someone is viewing the page: www.example.com?order=ASC&orderby=meta_value_num&meta_key=price (viewing properties in price order). Then the url $url = add_query_arg(array(‘meta_key’=>’bedrooms’,’orderby’=>’meta_value_num’)); Would give you www.example.com?order=ASC&orderby=meta_value_num&meta_key=bedrooms (the url to order properties by number of bedrooms). E.g: <?php $by_rooms= esc_url(add_query_arg(array(‘meta_key’=>’bedrooms’,’orderby’=>’meta_value_num’))); $by_price = esc_url(add_query_arg(array(‘meta_key’=>’price’,’orderby’=>’meta_value_num’))); … Read more

Dynamic iCal generator outside/inside wordpress

I would use WordPress’ feeds. You can create your own feed with add_feed. You specify a callback and this callback is responsible for displaying the output. Creating a feed add_feed(‘my-events’,’wpse56187_ical_cb’); wpse56187_ical_cb is that responsible for getting the events (use WP_Query), looping through them and printing the ICAL fields. Downloading the ICAL file If your feed … Read more

wordpress 3.4 template files in subdirectories

The solution shared in this answer on StackOverflow works for me: https://stackoverflow.com/questions/4647604/wp-use-file-in-plugin-directory-as-custom-page-template#answer-8255556 function get_book_post_type_template($single_template) { global $post; if ($post->post_type == ‘books’) { $single_template = dirname( __FILE__ ) . ‘/themefiles/single-books.php’; } return $single_template; } add_filter( “single_template”, “get_book_post_type_template” ) ;

Add specifications table for products page

You could easily do that with Product Specifications plugin. This plugin is built for this purpose and you won’t need any additional code, However it comes with a [specs-table] shortcode that you can use elsewhere. The plugin automatically adds a tab called “product specifications” to woocommerce single product page and shows product spec. table, Read … Read more

Show admin help message across custom post type parent and child posts

You’ll need to check the $pagenow variable and the post type of the post being edited. It will look something like this: function wpse_75224_admin_notices() { global $pagenow; $is_edit_custom_post_type = ( ‘post.php ‘ == $pagenow && ‘my_custom_post_type’ == get_post_type( $_GET[‘post’] ) ); $is_new_custom_post_type = ( ‘post-new.php’ == $pagenow && ‘my_custom_post_type’ == $_GET[‘post_type’] ); $is_all_post_type = ( … Read more