Remove 5 latest posts from the loop

I don’t know if WP has a built in feature for it’s query but you could do something like this: $count = 0; if(have_posts()) : while (have_posts()) : the_post(); if ($count < 4 ) { $count++; } else { … your blogroll code … } endwhile; endif;

Archive page – problem with pagination

Thanks Pat J I’have got solution now: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; ?> <?php $offset = ($paged – 1) * 4;?> <?php $kat = get_field(‘kategory’);?> <?php $query = new WP_Query(array(‘offset’ => $offset,’post_type’ => ‘modelki’, ‘taxonomy’ => $kat, ‘posts_per_page’ => ‘4’)); ?>

Carousel Loop only duplicating

You should reset the query after your active slider. So place this code after your first loop (after endwhile; endif; ): //Reset Query wp_reset_postdata(); Also try setting the paged atribute: $paged = ( get_query_var(‘paged’) ) ? get_query_var(‘paged’) : 1; // WP_Query arguments $args = array ( ‘post_parent’ => $destination->ID, ‘post_type’ => ‘page’, ‘posts_per_page’ => ‘4’, … Read more

Pagination not working in secondary query

The solution: <?php // building query $zephyr_cat = get_post_meta($post->ID, ‘zephyr_category’, true); $paged = is_front_page() ? get_query_var( ‘page’ ) : get_query_var( ‘paged’ ); if ( $zephyr_cat == 0 ) { $zephyr_q = new WP_query(‘posts_per_page=”.get_option(“posts_per_page’) . ‘&paged=’ . $paged); } else { $zephyr_q = new WP_query(‘cat=”.$zephyr_cat . “&paged=’ . $paged); } The explanation: the previous code was … Read more

How to do a loop inside a loop?

What if you save each query in a variable ? <ul> <?php $query1 = query_posts( array( ‘posts_per_page’ => -1, ‘post_type’ => array(‘specialties’) )); if($query1->have_posts()): while($query1->have_posts()): $query1->the_post(); ?> <li> <!– title from post type specialties –> <p><?php the_title(); ?></p> <ul> <?php $query2 = query_posts( array( ‘posts_per_page’ => -1, ‘post_type’ => array(‘team’) )); if($query2->have_posts()): while($query2->have_posts()): $query2->the_post(); ?> … Read more

Cannot exclude particular post from loop of custom post type

Something like this should work from your functions file as long as you use the correct conditional tag for your CPT archive: function exclude_single_post_cpt($query) { if (is_post_type_archive(‘event’) && $query->is_main_query() && !is_admin() ) { $query->set(‘post__not_in’, array(1646)); } } add_action(‘pre_get_posts’, ‘exclude_single_post_cpt’);

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