Displaying year, month and day archives differently

Conditional tags FTW. is_month() : Currently viewing a monthly archive is_day() : Currently viewing a single day archive is_year() : Currently viewing a yearly archive is_time() : Currently viewing a time-based archive (hourly, minute, or even seconds) So to test for each of these conditions, add something like this to your archive.php (or whatever template … Read more

Creating an Archive using a Custom Taxonomy

you can add the current term to you query so if its category, tag or custom taxonomy you will get the posts with the current term, try changing this: query_posts(‘cat=0&posts_per_page=12&paged=’.$paged); with this: $term_slug = get_query_var( ‘term’ ); $taxonomyName = get_query_var( ‘taxonomy’ ); query_posts(array(‘posts_per_page’ => 12, ‘paged’ => $paged, $taxonomyName => $term_slug));

How do I make archives.php for one category only?

First: don’t use query_posts(), ever. Second, to create a category archive index page template for a specific category, refer to the Codex entry for the Template Hierarchy: category-{slug}.php category-{id}.php category.php archive.php index.php So, if you have a category, ‘foobar’, with a category ID of 1, you could do either of the following: category-foobar.php category-1.php And … Read more

How to hide a post from archives

You’ll want to filter the main query via pre_get_posts callback. If you’ll only want to handle one specific post in this manner, you can reference/exclude its post ID directly. If, however, you want this same behavior for any future private posts, then I would query all posts with $post->post_status of private, and exclude them. One … Read more

Tell wordpress to show a single page instead of an archive

Here is a rough filter: add_filter( ‘template_include’, function($template) { global $wp_query; if (1 == $wp_query->found_posts) { global $wp_query; $type = $wp_query->get(‘post_type’) ?: false; $template_type = $type ? ‘single-‘ . $type. ‘.php’ : ‘single.php’; if ( locate_template($template_type) ) { return locate_template($template_type); } elseif ( $type && locate_template(‘single.php’) ) { return locate_template(‘single.php’); } } return $template; } … Read more

Multiple filters for wp_get_archive

Make use of custom parameter, lets call it wpse__current_year, which will accept two values, true (includes current year) and false (excludes current year). Lets incorporate that function show_monthly_archive( $post_type ) { $current_year_args = array( ‘type’ => ‘monthly’, ‘limit’ => ’12’, ‘format’ => ‘html’, ‘before’ => ”, ‘after’ => ”, ‘show_post_count’ => false, ‘echo’ => 1, … Read more

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