Display posts from #6 to #20 on archive page

Add offset in the query and give value as 5 so, the first 5 will be skipped. Below is code snippet for the same $custom_args = array(‘post_type’ => ‘your custom post type name’, ‘posts_per_page’ => ’20’, ‘orderby’ => ‘id’, ‘offset’=>5, ‘order’ => ‘ASC’,); $custom_query = get_posts($custom_args); foreach ($custom_query as $value) { //your data }

if there is only one post in the category, directly open

this function will check if you’re on a category page and 302 redirect to the latest post in that category. put it in your theme’s functions.php file. function my_check_if_cat(){ if ( is_category() ) : $category = get_the_category(); $latest = query_posts(‘showposts=1&cat=”.$category[0]->cat_ID); if(have_posts()) : wp_redirect(get_permalink($post->ID), 302); endif; endif; } add_action(“template_redirect’,’my_check_if_cat’);

Preview Post/Custom Post types in Archive

The get_posts method of WP_Query is what does the heavy lifting as far as getting the posts to display. Before it does anything, however, there’s a hook called pre_get_posts that you can hook into. The hooked function will receive a reference (pointer) to the current query object. So you can change the query vars to … Read more

Remove author archive

I would filter template_redirect, with an is_author() conditional, e.g.: function theme_slug_redirect_author_archive() { if ( is_author() ) { // Put your redirect code here; // Redirect to home_url(), or // return a 404, or whatever } } add_action( ‘template_redirect’, ‘theme_slug_redirect_author_archive’ );

Display all months with posts and inside each month show the 5 latest posts

one possibility is to run all posts through the loop and only output the month once per new month: <?php $counter = 0; $ref_month=””; $monthly = new WP_Query(array(‘posts_per_page’ => -1)); if( $monthly->have_posts() ) : while( $monthly->have_posts() ) : $monthly->the_post(); if( get_the_date(‘mY’) != $ref_month ) { if( $ref_month ) echo “\n”.'</ul>’; echo “\n”.'<h6>’.get_the_date(‘F’).'</h6>’; echo “\n”.'<ul>’; $ref_month … Read more

Show only post titles in archives?

You should take a look at content.php and do a check for is_post_type_archive() on whatever you want to hide. For example to hide the entry-meta section, you can do the following: <?php if ( !is_post_type_archive() ) { ?> <div class=”entry-meta”> <?php if ( ‘post’ == get_post_type() ) twentyfourteen_posted_on(); if ( ! post_password_required() && ( comments_open() … Read more

Custom Taxonomy Archive not displaying entries

I think you may need to filter the query for that taxonomy so it displays your movie custom post type. Try adding this to your theme’s functions.php file: function custom_post_archive($query) { if (!is_admin() && is_tax(‘genre’) && $query->is_tax) $query->set( ‘post_type’, array(‘movie’, ‘nav_menu_item’, ‘post’) ); remove_action( ‘pre_get_posts’, ‘custom_post_archive’ ); } add_action(‘pre_get_posts’, ‘custom_post_archive’); You’ll need to add to … Read more

Editable content on a Custom Archive page

You can use Options API or Setting API to store the data in the database. Write a plugin to create a meta box for the introduction text and show that text on the archive-unicorn.php. Or you can utilize the description parameter when you register_post_type and print it in the archive-unicorn.php like this: $unicorn_obj = get_post_type_object(‘unicorn’); … Read more

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