Hello guys i have got a code from stackexchange which is working somehow but giving one issue that the post repeating themself and no. of post per page is not working here is the code where i called the template
<?php
/**
* Loop - Archive
*
* This is the loop logic used on all archive screens.
*
* To override this loop in a particular archive type (in all categories, for example),
* duplicate the `archive.php` file and rename the duplicate to `category.php`.
* In the code of `category.php`, change `get_template_part( 'loop', 'archive' );` to
* `get_template_part( 'loop', 'category' );` and save the file.
*
* Create a duplicate of this file and rename it to `loop-category.php`.
* Make any changes to this new file and they will be reflected on all your category screens.
*
* @package WooFramework
* @subpackage Template
*/
global $more; $more = 0;
woo_loop_before();
if (have_posts()) { $count = 0;
$title_before = '<h1 class="archive_header">';
$title_after = '</h1>';
woo_archive_title( $title_before, $title_after );
// Display the description for this archive, if it's available.
woo_archive_description();
?>
<div class="fix"></div>
<ul id="archivelist">
<?php
while (have_posts()) { the_post(); $count++;
if(is_post_type_archive('styleword')) {get_template_part( 'content', 'stylewordall' );} else{woo_get_template_part( 'content', get_post_type() );}
} // End WHILE Loop
} else {
get_template_part( 'content', 'noposts' );
} // End IF Statement
woo_loop_after();?>
</ul>
<?php
woo_pagenav();
?>
and here is the code i used to call specific post types that is styleword and here is the code for it
<?php if ( false === ( $custom_query = get_transient( 'random_styleword' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$args = array(
'posts_per_page' => 5,
'post_type' => 'styleword',
'orderby'=> rand
);
$custom_query = get_posts( $args );
//Now we store the array for one day.
//Just change the last parameter for another timespan in seconds.
set_transient( 'random_styleword', $custom_query, DAY_IN_SECONDS );
}
foreach ( $custom_query as $post ) : setup_postdata( $post );
echo count($custom_query); ?>
<li><article <?php post_class(); ?>><div class="image-quote-wrapper">
<?php
$imagequote = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
$imagequoteurl = $imagequote['0'];
echo '<img src="'. $imagequoteurl .'" width="320px" class="nopin"/>';
?>
<span></span>
</div>
<div class="quote-share-panel quote-share-panel-flick">
<h2>Share This</h2>
<div class="social-links">
<a target="_blank" href="http://twitter.com/home?status=<?php echo urlencode(get_the_title())?>%20<?php echo urlencode(get_permalink())?>%20via%20%40FocusOnStyle"><i class="fa fa-twitter"></i></a>
<div class="pin-hold"><a target="_blank" href="http://www.pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink())?>&media=<?php echo urlencode($imagequoteurl)?>&description=%23styleword%20-%20<?php echo urlencode(get_the_title())?>"><i class="fa fa-pinterest"></i></a></div>
<a target="_blank" href="https://plus.google.com/share?url=<?php echo urlencode(get_permalink())?>"><i class="fa fa-google-plus"></i></a>
<a target="_blank" href="http://www.facebook.com/sharer/sharer.php?s=100&p[url]=<?php echo urlencode(get_permalink())?>&p[images][0]=<?php echo urlencode($imagequoteurl)?>&p[title]=<?php echo urlencode(get_the_title())?>"><i class="fa fa-facebook"></i></a>
<a target="_blank" href="mailto:email@example.com?Subject=%23styleword%20-%20<?php echo urlencode(get_the_title())?>&Body=%23styleword%20-%20<?php echo urlencode(get_the_title())?>%0A%0A%0A<?php echo urlencode(get_permalink())?>" title="email"><i class="fa fa-envelope-o"></i></a>
</div>
<a class="styleword-link" href="<?php echo get_permalink()?>"><i class="fa fa-long-arrow-right">View It Large</i></a>
</div></li></article>
<?php endforeach;
wp_reset_postdata(); ?>
and here u can see the code working Click Here