a-z list, categories and sub categories in loop

So you want to list the categories in a tree structure, in alphabetical order, showing ALL categories (even empty ones)? If so, try this: <?php $args = array(‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => false); $categories = wp_list_categories($args); ?> Reference: wp_list_categories

Help with Changing loop.php?

<?php if( is_archive() && is_category() && !is_tag() && !is_search() ): ?> <!– BEGIN .archive-title –> <h1 class=”page-title”> <?php if ( is_day() ): ?> <?php printf( __( ‘Daily Archives: %s’ ), get_the_date() ); ?> <?php elseif ( is_month() ): ?> <?php printf( __( ‘Monthly Archives: %s’ ), get_the_date( ‘F Y’ ) ); ?> <?php elseif ( … Read more

Exclude custom taxonomy tag from loop

I have rewritten the query_posts. As for get_posts you are better off using the WP_Query due to more control over the tax_query. Explained here. <?php $args = array( ‘cat’ => 84, ‘posts_per_page’ => 3, ‘offset’ => 0, ‘tax_query’ => array( ‘relation’ => ‘NOT IN’, array( ‘taxonomy’ => ‘display’, ‘field’ => ‘slug’, ‘terms’ => ‘featured-slider’ ) … Read more

Combining the_excerpt with the_content

The key is to use user-defined excerpts, rather than auto-generated excerpts. For example: <div <?php post_class(); ?>> <?php // If post has defined excerpt, output it here if ( has_excerpt() ) { ?> <div class=”first-paragraph-excerpt”> <?php the_excerpt(); ?> </div> <?php } // Now output the content the_content(); ?> </div> <!– .post –> You’ll need to … Read more

Force index.php have_posts() loop to exit if no sticky posts found

That is because get_option will return an empty array if there are no sticky posts and the query will default to everything. $sticky = get_option(‘sticky_posts’); if (!empty($sticky)) { $args[‘post__in’] = $sticky; $qry = new WP_Query(array(‘post__in’ => $sticky)); if ($qry->have_posts()) : while ($qry->have_posts()) : $qry->the_post(); echo $post->post_title; endwhile; endif; } And please don’t use query_posts.

Problem the_permalink

the_permalink() will echo the content immediately. You can’t use it for string concatenation. What is happening is that your permalink gets echoed by the_permalink() before the string is finished building, so the permalink ends up in the wrong place. What you need instead is get_the_permalink(). Side note: Because PHP’s echo will take multiple parameters, separating … Read more

Some doubts about how to show posts in a custom theme?

get_template_part() is including a template file from the active theme directory. For example: get_template_part(‘content’) will include the template content.php from the theme folder. When having two parameters, it will search for a template named firstParameter-secondParameter.php. So: get_template_part( ‘content’, get_post_format() ); will include the content-{$post_format}.php file. get_post_format() returns one of this defined formats: aside chat gallery … Read more