I am trying to create a related post section at the bottom of each post. I am using YARPP plugin to generate the related posts. I want customise the a template to show, a thumbnail(Done), title(Done) and a specific category(Issue).
My issue is its displaying all assigned categories, I only want to display one child category. I have a speaker category with child categories of the names of the speakers.
Let me know if you need more information. Thanks
<h3>Related Posts</h3>
<?php if ( have_posts() ) : ?>
<div>
<?php
while ( have_posts() ) : the_post(); ?>
<div>
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail( $dimensions['size'], array( 'data-pin-nopin' => 'true' ) ); ?></a>
<a href="<?php the_permalink(); ?>" rel="bookmark norewrite" title="<?php the_title_attribute(); ?>">
</div>
<div>
<?php the_title(); ?>
<!-- How to add specific category -->
<?php
$categories = get_the_category();
$separator = ' ';
$output = '';
if ( ! empty( $categories ) ) {
foreach( $categories as $category ) {
$term_id = '328';
$output .= '|| ' . esc_html( $category->name ) . '' . $separator;
}
echo trim( $output, $separator );
}
?>
<!-- How to add specific category END -->
</div>
<?php endif; ?>
<?php endwhile; ?>
</div>
<?php else : ?>
<p>No related photos.</p>
<?php endif; ?>
<?php $related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 6, 'post__not_in' => array($post->ID) ) );
if( $related ) foreach( $related as $post ) { setup_postdata($post); ?>
<div class="post">
<div class="post-title">
<h6 class="title"><?php the_title() ?></h6>
</div>
<div class="post-img" style="background-image: url(<?php the_post_thumbnail_url(); ?>)"></div>
</div>
<?php } wp_reset_postdata(); ?>
I am trying to add a particular shortcode to my theme, but i get an error when i paste the below code in my themes function.php. I already tried including once in the function.php but that did not work.
I think the problem is because of the <?php prefix and ?> suffix it has which is prohibited in wordpress fucntion.php. I had removed all <?php and ?> but it still generates an error.
// Add Shortcode
function acardio_big_grid_1() {
<div class="col-md-12 featt big-grid">
<div class="container-fluid no-padding">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('post_type' => 'post', 'posts_per_page' => 5, 'paged' => $paged);
$query = new WP_Query($args);
if( $query->have_posts() ) :
while( $query->have_posts() ) : $query->the_post(); ?>
<?php $count++; ?>
<?php if ($count == 1) : ?>
<div class="big-pane col-xs-6">
<div class="the-big-pane image">
<div class="img-responsive"> <?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail('big-grid-one-image'); ?>
<?php else : ?>
<img src="
<?php if (function_exists('get_option_tree') ) : if (get_option_tree('defualt_fatured_uploader')) : ?>
<?php get_option_tree( 'defualt_fatured_uploader', '', 'true' ); ?>
<?php else : ?>
<?php echo get_template_directory_uri (); ?>/img/nothumb-featured.png
<?php endif; endif; ?>
" />
<?php endif; ?></div>
</div>
<div class="big-pane overlay">
<div class="the-big-pane-content">
<div class="the-cont-cat">
<span class="the-content-cat-bt"> <?php $category = get_the_category(); if ($category)
{ echo wp_kses_post('<a href="' . get_category_link( $category[0]->term_id ) . '" class="tiptipBlog" title="' . sprintf( esc_html__( "View all posts in %s", "acardio" ), $category[0]->name ) . '" ' . '>' . $category[0]->name.'</a> ');} ?></span> <span class="the-content-cat-bt"> <?php taqyeem_get_score(); ?> </span>
</div>
<h1><?php echo wp_trim_words( get_the_title(), 15 ); ?></h1>
<span class="the-content-post-data"><span class="the-auth-post-image-content" style="padding-top: 0px !important;"> <?php echo get_avatar( get_the_author_meta( 'user_email' ), 100 ); ?> </span> By <?php the_author_posts_link(); ?> <span class="the-content-post-date"> <i class="fa fa-clock-o the-content "></i><?php the_time('jS M, Y') ?></span> </span>
</div>
</div>
</div>
<?php elseif ($count == 2) : ?>
<div class="small-pane-holder1 col-xs-6">
<div class="small-pane col-xs-6 one">
<div class="the-small-pane-image">
<?php the_post_thumbnail();?>
</div>
<div class="small-pane-overlay">
<div class="small-pan-content">
<div class="the-cont-cat">
<span class="the-content-cat-bt"> <?php $category = get_the_category(); if ($category)
{ echo wp_kses_post('<a href="' . get_category_link( $category[0]->term_id ) . '" class="tiptipBlog" title="' . sprintf( esc_html__( "View all posts in %s", "acardio" ), $category[0]->name ) . '" ' . '>' . $category[0]->name.'</a> ');} ?></span> <span class="the-content-cat-bt"> <?php taqyeem_get_score(); ?> </span>
</div>
<h1 class="small-pane-title"><?php echo wp_trim_words( get_the_title(), 10 ); ?></h1>
</div>
</div>
</div>
<?php elseif ($count == 3) : ?>
<div class="small-pane col-xs-6 two">
<div class="the-small-pane-image">
<?php the_post_thumbnail();?>
</div>
<div class="small-pane-overlay">
<div class="small-pan-content">
<div class="the-cont-cat">
<span class="the-content-cat-bt"> <?php $category = get_the_category(); if ($category)
{ echo wp_kses_post('<a href="' . get_category_link( $category[0]->term_id ) . '" class="tiptipBlog" title="' . sprintf( esc_html__( "View all posts in %s", "acardio" ), $category[0]->name ) . '" ' . '>' . $category[0]->name.'</a> ');} ?></span> <span class="the-content-cat-bt"> <?php taqyeem_get_score(); ?> </span>
</div>
<h1 class="small-pane-title"><?php echo wp_trim_words( get_the_title(), 10 ); ?></h1>
</div>
</div>
</div>
<?php elseif ($count == 4) : ?>
<div class="small-pane col-xs-6 three">
<div class="the-small-pane-image">
<?php the_post_thumbnail();?>
</div>
<div class="small-pane-overlay">
<div class="small-pan-content">
<div class="the-cont-cat">
<span class="the-content-cat-bt"> <?php $category = get_the_category(); if ($category)
{ echo wp_kses_post('<a href="' . get_category_link( $category[0]->term_id ) . '" class="tiptipBlog" title="' . sprintf( esc_html__( "View all posts in %s", "acardio" ), $category[0]->name ) . '" ' . '>' . $category[0]->name.'</a> ');} ?></span> <span class="the-content-cat-bt"> <?php taqyeem_get_score(); ?> </span>
</div>
<h1 class="small-pane-title"><?php echo wp_trim_words( get_the_title(), 10 ); ?></h1>
</div>
</div>
</div>
<?php elseif ($count == 5) : ?>
<div class="small-pane col-xs-6 four">
<div class="the-small-pane-image">
<?php the_post_thumbnail();?>
</div>
<div class="small-pane-overlay">
<div class="small-pan-content">
<div class="the-cont-cat">
<span class="the-content-cat-bt"> <?php $category = get_the_category(); if ($category)
{ echo wp_kses_post('<a href="' . get_category_link( $category[0]->term_id ) . '" class="tiptipBlog" title="' . sprintf( esc_html__( "View all posts in %s", "acardio" ), $category[0]->name ) . '" ' . '>' . $category[0]->name.'</a> ');} ?></span> <span class="the-content-cat-bt"> <?php taqyeem_get_score(); ?> </span>
</div>
<h1 class="small-pane-title"><?php echo wp_trim_words( get_the_title(), 10 ); ?></h1>
</div>
</div>
</div>
</div>
<?php else : ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
}
add_shortcode( 'acardio-big-grid-1', 'acardio_big_grid_1' );
Right near the top you have a syntax error - an issue with your PHP tags. You need a closing php tag before the HTML, and an opening PHP tag after. The top of the code should read like so:
function acardio_big_grid_1() {
?>
<div class="col-md-12 featt big-grid">
<div class="container-fluid no-padding">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('post_type' => 'post', 'posts_per_page' => 5, 'paged' => $paged);
You have a similar problem near the end of the code sample, but this time missing a opening php tag:
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
<?php
}
add_shortcode( 'acardio-big-grid-1', 'acardio_big_grid_1' );
No guarantees that that is all your issues, but that would be one key issue in the code sample you provided.
I'm doing a blog with Wordpress and the post pagination doesn't appear. The post list is shown correctly, but there is only 5 post (I have 8) and pagination isn't working.
<?php
if (have_posts()): while (have_posts()) : the_post(); ?>
<div class="all-post">
<?php
$args = array('category' => '');
$myposts = get_posts($args);
foreach ($myposts as $post) : setup_postdata($post); ?>
<div class="post">
<div class="post-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<div class="post-details">
<div class="post-meta">
<span class="date"><?php the_time('j M, Y'); ?></span>
<!-- Categories -->
<span class="categories">
<?php
$category_ids = get_all_category_ids();
?><?php
$args = array('orderby' => 'slug', 'parent' => 0);
$categories = get_categories($args);
foreach ($categories as $category)
{
echo '<a href="' . get_category_link(
$category->term_id
) . '" rel="bookmark" class="category">' . $category->name . '' . $category->description . '</a>';
} ?>
</span>
</div>
<h2 class="post-title">
<?php the_title(); ?>
</h2>
Read More
</div>
</div>
<?php endforeach;
wp_reset_postdata(); ?>
</div>
<?php endwhile; ?>
<?php next_posts_link('Older posts'); ?>
<?php previous_posts_link('Newer posts'); ?>
<?php else: ?>
<?php endif; ?>
You maybe didn't set any posts_per_page value and the default is 5. If you want to modifiy it for the whole website blog/archive pages, modify the posts_per_page value in the Reading Settings page.
In a $args array, modify as folow:
$args = array(
'posts_per_page'=> -1, // unlimited
'category' => ''
);
$posts = get_posts($args);
I'm prudent with my answer (that why I give 2 methods to achieve this), because I don't know with your given code, if the main loop $args is modify.
I hope this could nevertheless help you.
<div class="small-12 columns">
<ul class="category-filters">
<?php
$args = array(
'parent' => 0,
'exclude' => '1, 9'
);
$cats = get_categories($args);
foreach($cats as $cat) {
$output =
'<li>
<input class="checkbox" type="checkbox" value="' . $cat->cat_name . '">'
. $cat->cat_name .
'</li>';
echo $output;
}
?>
</ul>
<h4>Meet our Coaches</h4>
<?php
$wpb_all_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1));
if ( $wpb_all_query->have_posts() ) : ?>
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
<div class="callout horizontal word-wrap"
data-category="
<?php
$cats=get_the_category();
echo $cats[0]->cat_name;
?>">
<?php the_post_thumbnail() ?>
<h5><?php the_title(); ?></h5>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
I have the above php. It creates a list of checkboxes and then creates a list on callouts looping through all of the categories in wordpress.
I would like to know how I could modify this code so that it never creates and checkboxes or callouts for the category 'coaching'.
In addition to this question it would be great to know if there is a better way to get my desired outcome through something that wordpress has to offer that I have missed.
I have a problem in my template (wordpress).
I want to create a portfolio page which contains 3 columns and which can display posts in my portfolio page (without jumping a new page). And I need to repeat these three posts after each third post. I will assign "hidden" class to my duplicate posts and when clicking at the column, class shall set as "block".
I have a code:
<?php get_header(); ?>
<section> <div class="container container-bazar container-gallery"><?php
$array = array();
$count = 0;
$i = 0;
$args = array(
'posts_per_page' => -1,
'post_type' => 'gallery',
);
$gallery = new WP_Query( $args );
if($gallery->have_posts()) :
while($gallery->have_posts()) :
$gallery->the_post(); ?>
<div class="col-1 boxes<?php if( $count%3 == 0 ) { echo '-1'; }; $count++; ?>">
<div class="post" id="post-<?php the_ID(); ?>">
<figure class="indent-bot">
<a href="<?php the_permalink(); ?>" rel="nofollow">
<?php the_post_thumbnail(array(380,220,true)); ?>
</a>
</figure>
<div class="col-1-content">
<strong class="title-3">
<a href="<?php the_permalink(); ?>" rel="nofollow">
<?php the_title(); ?>
</a>
</strong>
<div class="entry">
<a href="<?php the_permalink(); ?>" rel="nofollow">
<?php the_excerpt(); ?>
</a>
</div><!-- .entry -->
</div><!-- .col-1-content-->
</div><!-- .post -->
</div> <!-- .boxes -->
<?php endwhile; ?>
<?php while($gallery->have_posts()) :
$gallery->the_post();?>
<?php $imgaddr1 = get_post_meta($post->ID, 'imgaddr1', true);
$imgaddr2 = get_post_meta($post->ID, 'imgaddr2', true);
$imgssilka1 = get_post_meta($post->ID, 'imgssilka1', true);
$imgssilka2 = get_post_meta($post->ID, 'imgssilka2', true);
$namecolor1 = get_post_meta($post->ID, 'namecolor1', true);
$namecolor2 = get_post_meta($post->ID, 'namecolor2', true);
$numbercolor1 = get_post_meta($post->ID, 'numbercolor1', true);
$numbercolor2 = get_post_meta($post->ID, 'numbercolor2', true); ?>
</div>
<div class="full clearfix">
<div class="inner">
<figure class="indent-bot1">
<a href="<?php the_permalink(); ?>" rel="nofollow">
<?php the_post_thumbnail(array(960,690)); ?>
</a>
</figure>
<div class="row">
<div class="col-md-5">
<div class="inf-1">
<h4>Информация</h4>
</div>
<div class="inf-2">
<h5><?php the_title(); ?></h5>
<div class="desc">
<?php the_excerpt(); ?>
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="col-md-7 border-left">
<div class="inf-1">
<h4>Приложенные Цвета</h4>
</div>
<div class="inf-2">
<ul>
<li class="first-child">
<a href="<?php echo $imgssilka1; ?>" class="img-block">
<img src="<?php echo $imgaddr1; ?>">
</a>
<div class="txt">
<strong><?php echo $namecolor1; ?></strong>
<span><?php echo $numbercolor1; ?></span>
</div>
</li>
<li class="last-child">
<a href="<?php echo $imgssilka2; ?>" class="img-block">
<img src="<?php echo $imgaddr2; ?>">
</a>
<div class="txt">
<strong><?php echo $namecolor2; ?></strong>
<span><?php echo $numbercolor2; ?></span>
</div>
</li>
</ul>
</div>
<div class="clearfix"></div>
</div>
</div>
</div><!-- .inner -->
</div>
<div class="container container-bazar container-gallery">
<?php endwhile;
else:
endif; ?>
</div><!-- .container -->
</section>
<?php get_footer(); ?>
but this code displays posts sequentially.
$i = 1;
//added before to ensure it gets opened
echo '<div>';
if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();
// post stuff...
// if multiple of 3 close div and open a new div
if($i % 3 == 0) {echo '</div><div>';}
$i++; endwhile; endif;
//make sure open div is closed
echo '</div>';
This is quite an unusual setup which had me thinking. There is a way without rerunning the loop
HERE IS HOW
You need to run your loop only once. In stead of the default loop, we will pull out our posts array from our query and run our posts through a foreach loop. This is where we will start things
We need to split our content up so we can get two blocks with post data, and this need to be saved into an array which we will use later. To achieve this, build two concatenated strings of data ( one string with the first block of data and the second one with the second block of data ) which will be saved in two separate variables.
Once this is done, we need to add our divs to form blocks of posts containing three posts, each with a unique class. This goes for both sets of string
Now we need to calculate new array keys so we can build a new array of post data sorted so we have a sequence of a block of post data with three posts from string one, then a block of post data with the same three posts from string two etc
Finally, because our array of posts is still mixed and is out of order, we will sort the array so the keys are numerical, then we can use a last foreach loop to output our post data
HERE IS THE CODE
Just a note or two before I post the code
You need to modify the classes etc to suite your needs
The code is not fully tested, but the div blocks and sorting works as expected
I have commented the code to make it easier to follow
Finally, the code
$args = array(
'posts_per_page' => -1,
'post_type' => 'gallery',
);
$gallery = new WP_Query( $args );
// Check if we have posts before we continue
if( $gallery->have_posts() ) {
// Use the array of posts and a foreach loop to build out super array
foreach ( $gallery->posts as $key=>$post ) {
// Setup postdata so we can make use of template tags
setup_postdata( $post );
// Setup/define our first variable which will hold our first set of post data
$output = '';
// Open a new div on the first post and every 3rd one there after to hold three posts
if ( $key%3 == 0 ) {
// We will call this class "first-x" where x represents the block count
$output .= '<div class="first-' . floor( $key / 3 ) . '">';
}
// Concatenate your first loop into a string to our first variable $output
$output .= '<div class="post" id="post-' . $post->ID . '">
<figure class="indent-bot">
<a href="' . get_the_permalink() . '" rel="nofollow">
' . get_the_post_thumbnail( $post->ID, array( 380,220,true ) ) . '
</a>
</figure>
<div class="col-1-content">
<strong class="title-3">
<a href="' . get_the_permalink() . '" rel="nofollow">
' . get_the_title() . '
</a>
</strong>
<div class="entry">
<a href="' . get_the_permalink() . '" rel="nofollow">
' . get_the_excerpt() . '
</a>
</div><!-- .entry -->
</div><!-- .col-1-content-->
</div><!-- .post -->
</div> <!-- .boxes -->';
// Add our closing div after every third post or the last post if there is less than three
if ( $key%3 == 2 || !array_key_exists( ( $key + 1 ), $gallery->posts ) ) {
$output .= '</div>';
}
// Create our new array of post data split in two and use with new array keys
$new_posts_array[floor( $key / 3 ) * 3 + $key] = $output;
// Setup/define our second variable which will hold the second set of post data from our posts
// This is the set that you would like to hide
$output_1 = '';
// Open a new div on the first post and every 3rd one there after to hold three posts
if ( ( $key%3 ) == 0 ) {
// This block of posts will use class "second-x" where x represents the block count
$output_1 .= '<div class="second-' . floor( $key / 3 ) . '">';
}
$imgaddr1 = get_post_meta( $post->ID, 'imgaddr1', true );
$imgaddr2 = get_post_meta( $post->ID, 'imgaddr2', true );
$imgssilka1 = get_post_meta( $post->ID, 'imgssilka1', true );
$imgssilka2 = get_post_meta( $post->ID, 'imgssilka2', true );
$namecolor1 = get_post_meta( $post->ID, 'namecolor1', true );
$namecolor2 = get_post_meta( $post->ID, 'namecolor2', true );
$numbercolor1 = get_post_meta( $post->ID, 'numbercolor1', true );
$numbercolor2 = get_post_meta( $post->ID, 'numbercolor2', true );
// Concatenate your second set of post data into a string to our second variable $output_1
$output_1 .= '<div class="full clearfix">
<div class="inner">
<figure class="indent-bot1">
<a href="' . get_the_permalink() . '" rel="nofollow">
' . get_the_post_thumbnail( $post->ID, array( 960, 690 ) ) . '
</a>
</figure>
<div class="row">
<div class="col-md-5">
<div class="inf-1">
<h4>Информация</h4>
</div>
<div class="inf-2">
<h5>' . get_the_title() . '</h5>
<div class="desc">
' . get_the_excerpt() . '
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="col-md-7 border-left">
<div class="inf-1">
<h4>Приложенные Цвета</h4>
</div>
<div class="inf-2">
<ul>
<li class="first-child">
<a href="' . $imgssilka1 . '" class="img-block">
<img src="' . $imgaddr1 . '">
</a>
<div class="txt">
<strong>' . $namecolor1 . '</strong>
<span>' . $numbercolor1 . '</span>
</div>
</li>
<li class="last-child">
<a href="' . $imgssilka2 . '" class="img-block">
<img src="' . $imgaddr2 . '">
</a>
<div class="txt">
<strong>' . $namecolor2 . '</strong>
<span>' . $numbercolor2 . '</span>
</div>
</li>
</ul>
</div>
<div class="clearfix"></div>
</div>
</div>
</div><!-- .inner -->
</div>';
// Add our closing div after every third post or the last post if there is less than three
if ( $key%3 == 2 || !array_key_exists( ( $key + 1 ), $gallery->posts ) ) {
$output_1 .= '</div>';
}
// Create our new array of post data split in two and use with new array keys
$new_posts_array[( floor( $key / 3 ) + 1 ) * 3 + $key] = $output_1;
}
wp_reset_postdata();
// Sort our new array so that the keys are numerical again
ksort( $new_posts_array );
// Run a foreach loop to output our posts as we need. No need to modify anything here
foreach ( $new_posts_array as $v )
echo $v;
}
As we all know, WordPress is an open source tool and all plugins are available to manage such formatting.
I recommend to go with plugins to manage your requirements. I have used columns plugin for formatted output.
I got the total number of records and made the loop.
Inside the loop, two-cycle.
First loop displays a table. The second cycle displays a list.
<section>
<div class="container container-gallery">
<?php
$offset = 0;
$offset1 = 0;
$i =0;
$count = 0;
$reset =0;
$reset1 = 0;
$args = array(
'posts_per_page' => -1,
'post_type' => 'gallery',
);
$gallery = new WP_Query( $args );
$numberposts = $gallery->post_count;
if ($numberposts){
$id1=0;
$id2=0;
while($count < $numberposts){
// print_r($arr1);
$count++;
//echo "<h2>".$count."</h2>";
$arr1 = array(
'posts_per_page' => 400,
'post_type' => 'gallery',
'offset'=>$offset
);
$arr2 = array(
'posts_per_page' => 400,
'post_type' => 'gallery',
'offset'=>$offset1
);
$loop1 = new WP_Query($arr1);
$loop2 = new WP_Query($arr1);
while($loop1->have_posts()) : $loop1->the_post();
if ($reset<3) :
$reset++;
?>
<?php
$colorfilter1 = get_post_meta($post->ID, 'checkboxwhite', true);
$colorfilter2 = get_post_meta($post->ID, 'checkbox_beige', true);
$colorfilter3 = get_post_meta($post->ID, 'checkbox_brown', true);
$colorfilter4 = get_post_meta($post->ID, 'checkbox_gray', true);
$colorfilter5 = get_post_meta($post->ID, 'checkbox_black', true);
$colorfilter6 = get_post_meta($post->ID, 'checkbox_vvid', true);
if ($colorfilter1 != "") $colorfilter1 ="white ";
if ($colorfilter2 != "") $colorfilter2 ="beige ";
if ($colorfilter3 != "") $colorfilter3 ="brown ";
if ($colorfilter4 != "") $colorfilter4 ="gray ";
if ($colorfilter5 != "") $colorfilter5 ="black ";
if ($colorfilter6 != "") $colorfilter6 ="vivid ";
$class_color = $colorfilter1.$colorfilter2.$colorfilter3.$colorfilter4.$colorfilter5.$colorfilter6;
?>
<div class="col-1 mcol boxes<?php if( $i%3 == 0 ) { echo '-1'; }; $i++; echo ' '.$class_color;?>" id="colbox<?php echo $id1; $id1++;?>" data-id="click" >
<div class="post" id="post-<?php the_ID(); ?>">
<figure class="indent-bot">
<?php the_post_thumbnail(array(380,220,true)); ?>
</figure>
<div class="col-1-content">
<strong class="title-3">
<?php the_title(); ?>
</strong>
<div class="entry">
<?php the_excerpt(); ?>
</div><!-- .entry -->
</div><!-- .col-1-content-->
</div><!-- .post -->
</div><!-- .boxes -->
<?php else : break;?>
<?php endif; ?>
<?php endwhile; ?>
<?php
$reset = 0;
$offset +=3;
?>
<?php wp_reset_postdata(); ?>
<?php
while($loop2->have_posts()) : $loop2->the_post();
if ($reset1<3) :
$reset1++;
?>
<?php
$numbercolor1 = get_post_meta($post->ID, 'numbercolor1',true);
$numbercolor2 = get_post_meta($post->ID, 'numbercolor2', true);
$imgaddr1 = get_post_meta($post->ID, 'imgaddr1', true);
$imgaddr2 = get_post_meta($post->ID, 'imgaddr2', true);
$imgssilka1 = get_post_meta($post->ID, 'imgssilka1', true);
$imgssilka2 = get_post_meta($post->ID, 'imgssilka2', true);
$namecolor1 = get_post_meta($post->ID, 'namecolor1', true);
$namecolor2 = get_post_meta($post->ID, 'namecolor2', true);
?>
</div>
<div class="full clearfix active colbox<?php echo $id2; $id2++;?>" id="">
<div class="inner">
<figure class="indent-bot1">
<a href="<?php the_permalink(); ?>" rel="nofollow">
<?php the_post_thumbnail(array(960,690)); ?>
</a>
</figure>
<div class="row">
<div class="col-md-5">
<div class="inf-1">
<h4>Информация</h4>
</div>
<div class="inf-2">
<h5><?php the_title(); ?></h5>
<div class="desc">
<?php the_excerpt(); ?>
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="col-md-7 border-left">
<div class="inf-1">
<h4>Приложенные<</h4>
</div>
<div class="inf-2">
<ul>
<li class="first-child">
<a href="<?php echo $imgssilka1; ?>" class="img-block">
<img src="<?php echo $imgaddr1; ?>">
</a>
<div class="txt">
<strong><?php echo $namecolor1; ?></strong>
<span><?php echo $numbercolor1; ?></span>
</div>
</li>
<li class="last-child">
<a href="<?php echo $imgssilka2; ?>" class="img-block">
<img src="<?php echo $imgaddr2; ?>">
</a>
<div class="txt">
<strong><?php echo $namecolor2; ?></strong>
<span><?php echo $numbercolor2; ?></span>
</div>
</li>
</ul>
</div>
<div class="clearfix"></div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="c_btn"></div>
</div>
</div>
</div><!-- .inner -->
</div>
<div class="container container-gallery">
<?php else : break;?>
<?php endif; ?>
<?php endwhile; ?>
<?php
$reset1 = 0;
$offset1 +=3;
?>
<?php wp_reset_postdata(); ?>
<?php
} //end if ($count <= $numberposts)
} //end if ($numberposts)
?>
<?php
if ( have_posts() ) while ( have_posts() ) : the_post(); // старт цикла ?>
<article id="post-<?php the_ID(); ?>">
<?php the_content(); ?>
</article>
<?php endwhile; ?>
</div><!-- .container -->
</section>