Least Number of Loops to Create Custom Homepage?

You can achieve this by checking where you are in the loop and outputting markup at the appropriate time. Within the object that holds the query results is a counter that keeps track of the current post, $wp_query->current_post. Note that it is zero-indexed, so first is 0, 2nd is 1, etc.. <?php while( have_posts() ): … Read more

Paged homepage – requirements?

If you put the following after the while loop, does it link to anything? <?php next_posts_link(‘&laquo; previous posts’); if (get_next_posts_link() && get_previous_posts_link()) echo ‘ | ‘; previous_posts_link(‘next posts &raquo;’); ?>

Load featured article once in a loop

I was able to find a solution to my own problem. For anyone needing to solve this in the future, WordPress offers a set of conditional statements for just able everything, include pagination. <?php get_header(); ?> <?php if ( ! $paged || $paged < 2 ){ ?> <?php locate_template( ‘featured-post.php’, true, false ); ?> <?php … Read more

How to create an identical second loop for attachments?

You don’t need a second loop. Just save all the data you need later during the first loop. Sample code, not tested, just a hint: <ul class=”ei-slider-large”> <?php // Here we store the data. $second_loop = array(); // Main loop $main_query = new WP_Query( array( ‘category_name’ => ‘featured’, ‘posts_per_page’ => 3 ) ); if( $main_query->have_posts() … Read more

Show last post from multiple categories using wp_list_categories

Get all children categories using get_terms(). Loop through each term and run a new query using tax_query. Example: <?php if ( get_queried_object()->parent == 0 ) : // parent cat ?> <h2>Showing all children</h2> <?php $args = array( ‘hide_empty’ => false, ‘parent’ => get_queried_object()->term_id ); $terms = get_terms( ‘category’, $args ); if ( $terms ) echo … Read more

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