Event Archive by Month

Ok short of a better solution here is what I’ve come up with: <?php $today = date(‘Y-m-d’, strtotime(‘-6 hours’)); query_posts(array( ‘post_type’ => ‘events’, ‘posts_per_page’ => 99, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘meta_query’ => array(array( ‘key’ => ‘event_date’, ‘meta-value’ => $value, ‘value’ => $today, ‘compare’ => ‘>=’, ‘type’ => ‘CHAR’ )) )); … Read more

Creating ‘posts page’ loop based on the page itself

You can get the selected page for posts by the following code: $page_for_posts = get_option( ‘page_for_posts’ ); Then, get the requested post by: $post = get_post( $page_for_posts ); And, get the data you need: echo apply_filters( ‘the_title’, $post->post_title ); echo apply_filters( ‘the_content’, $post->post_content ); echo get_post_meta( $post->ID, $key, $single);

Use an archive as the parent of a page?

Once wordpress reads the “Events” part of the URL it knows that what follows are posts or subcategories of the events category, and a page is neither, and that is the reason you don’t even have an option of doing what you want. Do it as a post instead of a page. Then edit you … Read more

Find out in which kind of archive am I

Inspect get_queried_object(). On an archive for the category Uncategorized you get something like … stdClass Object ( [term_id] => 1 [name] => Uncategorized [slug] => uncategorized [term_group] => 0 [term_taxonomy_id] => 1 [taxonomy] => category Find out in which kind of archive am I => [parent] => 0 [count] => 8 [cat_ID] => 1 [category_count] … Read more

Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy

This is minimally tested– nearly untested really– but: function force_archive_php_wpse_88824() { if (is_main_query() && is_archive()) { include (get_stylesheet_directory().’/archive.php’); exit; } } add_action(‘template_redirect’,’force_archive_php_wpse_88824′); You are interrupting the template load process and forcing a file of your choice to be used. Reference http://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect http://codex.wordpress.org/Function_Reference/get_stylesheet_directory

Add multiple orderby with pre get posts

You could try using the posts_orderby filter: add_filter(‘pre_get_posts’, ‘sort_arc’); function sort_arc($q) { if ($q->is_category() && $q->is_main_query()) { $q->set(‘meta_key’, ‘the-year’); add_filter(‘posts_orderby’, ‘custom_posts_orderby’); } return $q; } where function custom_posts_orderby($orderby) { global $wpdb; return $wpdb->postmeta.”.meta_value+0 DESC, “.$wpdb->posts .”.post_title ASC”; } takes care of the custom ordering. We use meta_value+0 from the meta_value_num definition in /wp-includes/query.php. Update: Here … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)