Total Count of Posts NOT in Selected Categories?

Do your posts have multiple categories? If not – I think individual category counts are cached, so can sum up counts: $categories = get_categories( array( ‘exclude’ => $folio_cat_ids ) ); $count = 0; foreach ( $categories as $category) $count += $category->category_count; Can also just get and count the posts, that is more flexible and takes … Read more

Loop with break in the middle

Try using a loopcounter based on the post number count – provides for more flexibility <?php if (have_posts()) : ?> <?php $count = 0; ?> <?php while (have_posts()) : the_post(); ?> <?php $count++; ?> // if you are in your first post <?php if ($count == 1) : ?> // do whatever you want to … Read more

WordPress search exact match

You might want to append the query parameter sentence=1 in your search, it is not well documented, but it should retrieve content inside the post that matches exactly the sentence pattern. Alternatively, for a more powerful search, you might want to give a look at Relevanssi plugin. A lot of people agree that WordPress search … Read more

WP_Query on custom post type not displaying, multiple loops & get_template_part

I think you forgot to check if $the_query have posts. <?php $args = array( ‘post_type’ => ‘testimonials’, ‘posts_per_page’ => 1, ‘orderby’ => ‘rand’ ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class=”testimonial push_2 grid_10 clearfix”> <blockquote>&ldquo;<?php the_field( ‘testimonial’ ); ?>&rdquo;</blockquote> <cite>&mdash;<?php … Read more

Loop inside the loop

I would use get_posts() for your two ad hoc Loops. (Actually, you only need one ad hoc Loop, if you’re modifying the main Loop so that only 2 posts are retrieved.) e.g. \\ code modify main Loop to return only 2 posts goes here $firstpost = true; if ( have_posts() ) : while ( have_posts() … Read more

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