www.webdeveloper.com
Results 1 to 5 of 5

Thread: code help

  1. #1
    Join Date
    Jan 2014
    Posts
    3

    code help

    Hello,

    how do I make it get posts alphabetically?

    Thank you


    <center>
    <form action="<? bloginfo('url'); ?>" method="get">
    <select name="page_id" id="page_id">
    <?php
    global $post;
    $args = array( 'numberposts' => -1);

    $posts = get_posts($args);

    foreach( $posts as $post ) : setup_postdata($post); ?>
    <option value="<? echo $post->ID; ?>"><?php the_title(); ?></option>
    <?php endforeach; ?>
    </select>
    <input type="submit" name="submit" value="Cмотреть фильм" />
    </form>
    </center>

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,614
    PHP Code:
    sort($posts); 
    ?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Jan 2014
    Posts
    3
    Thank you, where do I add this code? Also how do I change size of the form?

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,614
    You add it after you define $posts via your get_posts() function, but before the beginning of the foreach() loop where you loop on it. (Which leaves you very little wiggle room. )

    As far as size of the form, that sounds more like a HTML/CSS issue than a PHP question?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Jan 2014
    Posts
    3
    Thank you, it worked. I will check my CSS. Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles