Grow your CSS skills. Land your dream job.

Ordered lists with PHP? (WordPress)

  • # August 18, 2012 at 5:06 pm

    Overall what I’m trying to do is list the number of attachments (1, 2, etc) for each post on a page. When you click on a number, it will change the image. Pretty much like a slideshow. How would I go about adding the numbers in my loop or could this be better solved via jQuery?

    The reason I am not using OL’s is because it outputs a period after the number which I absolutely do not want.

    Code (so far):

    < ?php
    if( function_exists( 'attachments_get_attachments' ) )
    {
    $attachments = attachments_get_attachments();
    $total_attachments = count( $attachments );
    if( $total_attachments ) : ?>

      < ?php for( $i=0; $i<$total_attachments; $i++ ) : ?>
    • ">

    • < ?php endfor; ?>

    < ?php endif; ?>
    < ?php } ?>

    Desired Output (view source HTML):

  • 1

  • 2

  • 3
  • # August 18, 2012 at 6:06 pm

    Solution:

    < ?php
    if( function_exists( 'attachments_get_attachments' ) )
    {
    $attachments = attachments_get_attachments();
    $total_attachments = count( $attachments );
    if( $total_attachments ) : ?>

    < ?php endif; ?>
    < ?php } ?>
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".