• Midhun007

    (@midhun007)


    I want to show the posts under a category in my page.The first 5 posts should be shown when the page loads and When the user clicks the next button/link next 5 posts should be shown. The following is the template I use to show all the posts under that category.

    <div id="bloggers">
    <?php $bloggers = new wp_Query("category_name=bloggers-blog&order=ASC&orderby=ID");?>
    <?php
    while ($bloggers->have_posts() ) :$bloggers->the_post();
    $blogger_name = get_post_custom_values("blogger_name");
    $blogger_desig = get_post_custom_values("blogger_desig");
    $blogger_profile = get_post_custom_values("blogger_profile");
    ?>
    <div id="blogger_contents">
    <h1 style="font-weight:bold;font-size:16px;margin-top:10px;"><?php the_title();?></h2>
    <div id="blogger_image">
        <?php
            if ( has_post_thumbnail() )  {
                the_post_thumbnail();
            }
        ?>
    </div>
    <div id="blogger_name">
        <?php
            if( is_array( $blogger_name ) )
            {
                foreach($blogger_name as $key => $value );
                echo "$value</n>";
            }
        ?>
    </div>
    <div id="blogger_desig">
        <?php
            if( is_array( $blogger_desig ) )
            {
                foreach($blogger_desig as $key => $value );
                echo "$value</n></n>";
            }
        ?>
    </div>
    <div id="blogger_profile">
        <?php
            if( is_array( $blogger_profile ) )
            {
                foreach($blogger_profile as $key => $value );
                echo "$value</n>";
            }
        ?>
    </div>
    
    <div id="options_to_connect" class="<?php the_ID();?>">
        <a class="lbp-inline-link-1 cboxElement " href="#">Options To Connect</a>
    </div>
    </div>
    
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>
    <a href="#" class="prev">prev</a>
    <a href="#" class="next">next</a>
    </div>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Show first 5 posts in a category on page load and next 5 on clicking the next bu’ is closed to new replies.