• Resolved tom_taylor_85

    (@tom_taylor_85)


    If you look at https://mtv.com on the right hand side under “Hot Videos” I want to make the posts I make in categories to be numbered in numerical order…

    what code would I use???

    Thank you!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter tom_taylor_85

    (@tom_taylor_85)

    anyone know???

    take variable $count and initialize first is 0. inside the loop $count will be incremented by one($count++). Now print the variable. code is : echo $count;

    Thread Starter tom_taylor_85

    (@tom_taylor_85)

    ^^It still won’t let me count the posts…^^

    Is this the right code? <?php echo $count; ?>

    yes.

    Thread Starter tom_taylor_85

    (@tom_taylor_85)

    tried that…where would I need to add that for it to work?

    And do I need to add anything in my other files?

    can you give your sidebar.php file?

    Thread Starter tom_taylor_85

    (@tom_taylor_85)

    This is without me adding the code you told me to add.

    <tr>
    
       <td bgcolor="#183152"><div class="style19" id="homepageleft">
    
          <div class="hpfeatured">
    
            <div class="mdl">
    
      <div class="h-wrap group">
    
        <h2 class="h-sub2 group"> <span>VIDEOS</span> </h2>
      </div>
    </div>
    
    <br/>
    
           <?php $recent = new WP_Query("cat=98&showposts=10"); while($recent->have_posts()) : $recent->the_post();?>
            <?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
    
            <a href="<?php the_permalink() ?>" rel="bookmark"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="<?php the_title(); ?>" width="65" border="1" style="float:left;margin:0px 10px 0px 0px;" /></a>
    
            <?php else: ?>
    
            <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;"  src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a>
    
            <?php endif; ?>
    
            <b>        <img src="/wp-content/uploads/2009/09/play.jpg" /><a href="<?php the_permalink() ?>" rel="bookmark">
    
          <?php the_title(); ?></a></b>
    		<br/>
    		<br/>
    		<?php the_time('F jS, Y') ?>  
    
            <div style="border-bottom:1px dotted #94B1DF; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div>
    
            <?php endwhile; ?>
    
            <div class="more-link"><a href="/updates/category/video/" rel="bookmark"> More Videos +</a></div>
          </div>
    
        </div></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    <tr>
    
       <td bgcolor="#183152"><div class="style19" id="homepageleft">
    
          <div class="hpfeatured">
    
            <div class="mdl">
    
      <div class="h-wrap group">
    
        <h2 class="h-sub2 group"> <span>VIDEOS</span> </h2>
      </div>
    </div>
    
    <br/>
    
           <?php
    $count = 0;
    $recent = new WP_Query("cat=98&showposts=10");
    while($recent->have_posts()) : $recent->the_post();?>
    <b><?php echo ++$count; ?></b>
            <?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
    
            <a href="<?php the_permalink() ?>" rel="bookmark"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="<?php the_title(); ?>" width="65" border="1" style="float:left;margin:0px 10px 0px 0px;" /></a>
    
            <?php else: ?>
    
            <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;"  src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a>
    
            <?php endif; ?>
    
            <b>        <img src="/wp-content/uploads/2009/09/play.jpg" /><a href="<?php the_permalink() ?>" rel="bookmark">
    
          <?php the_title(); ?></a></b>
    		<br/>
    		<br/>
    		<?php the_time('F jS, Y') ?>  
    
            <div style="border-bottom:1px dotted #94B1DF; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div>
    
            <?php endwhile; ?>
    
            <div class="more-link"><a href="/updates/category/video/" rel="bookmark"> More Videos +</a></div>
          </div>
    
        </div></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>

    First keep a backup of sidebar.php, then replace the code.

    Thread Starter tom_taylor_85

    (@tom_taylor_85)

    Awesome, thank you very much! It worked like a charm. And if I want to change the placement, all I do is move this: <b><?php echo ++$count; ?>.</b> and $count = 0;

    Correct?

    yes. You move it according your choice.

    Please mark this topic as resolved.

    Thanks
    Chinmoy
    https://chinmoy29.wordpress.com

    Thread Starter tom_taylor_85

    (@tom_taylor_85)

    Done, thanks a bunch!

    you’re welcome:)

    Thread Starter tom_taylor_85

    (@tom_taylor_85)

    Sorry to bother you again…but is there a way to display the numbers in front of the picture? Just like mtv.com?

    Would I need to use a div category, or is it the placement of the codes that matters?

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How do I number my posts? (1, 2, 3, 4, etc.)’ is closed to new replies.