How to make a list of posts displaying them 5 by 5 with a “next posts” link?

I found the actual answer in a stackoverflow question. Quoted from the answer: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 10, ‘paged’ => $paged ); $wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?> <h2><?php the_title() ?></h2> <?php endwhile; ?> <!– then the pagination … Read more

Split custom post list into two columns

You could count the number of items and insert </ul><ul> after 50%. Sample code, not tested: if ($postslist) { $count = 1; if($top) echo ‘<h4>’.$name.'</h4>’; echo ‘<ul>’; foreach ( $postslist as $post ) { echo ‘<li><a href=”‘.get_permalink($post->ID).'”>’.get_the_title($post->ID).”</a></li>”; if ( 0 === $count % 10 ) echo ‘</ul><ul>’; $count += 1; } echo ‘</ul>’; } And … Read more

Listing category

If you know the depth that you want you can add a depth parameter to $args $args = array( ‘orderby’ => ‘id’, ‘show_count’ => ‘0’, ‘child_of’ => $this_category->term_id, ‘use_desc_for_title’ => ‘0’, ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => ‘0’, ‘child_of’ => $this_category->term_id, ‘depth’ => 2 ); wp_list_categories($args); Experiment with that number if it isn’t what you want. … Read more

Create shortcode for list of custom post titles with custom fields alongside

Try the following code: (I’ve not tested it, so there might be few things here and there, but you can get the overall idea): add_shortcode(‘boats’, ‘shortcode_boats’); function shortcode_boats($atts){ //merge the passed attributes with defaults extract( shortcode_atts( array( ‘post_type’ => ‘yacht-for-sale’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 15, ‘caller_get_posts’ => 1 //i am not sure what you … Read more

AZ Directory category

I wrote a tutorial on Creating an Alphabetical Glossary of Posts but here are the most relevant parts. First create a hidden taxonomy for the letters of the alphabet // Add new taxonomy, NOT hierarchical (like tags) function kia_create_glossary_taxonomy(){ if(!taxonomy_exists(‘glossary’)){ register_taxonomy(‘glossary’,array(‘post’),array( ‘show_ui’ => false )); } } add_action(‘init’,’kia_create_glossary_taxonomy’); Then when any post is saved, save … Read more

Create a Page Template Which Displays All Posts by Current User

Working code: <?php if (is_user_logged_in() ) : ?> <?php //if a certain page, then display posts authored by the logged in user $page_title=”Support History”; if ( is_user_logged_in() && is_page($page_title) ) { global $current_user; get_currentuserinfo(); $args=array( ‘author’ => $current_user->ID, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish, private’, ‘posts_per_page’ => -1, ‘caller_get_posts’=> 1 ); $my_query = null; $my_query … Read more