Wordpress display all post link in x category

Discussion in 'PHP' started by tomcromp, Apr 4, 2010.

  1. #1
    Hello what code would i use to display post links from "x" category

    Cheers
    Tom
     
    tomcromp, Apr 4, 2010 IP
  2. Sweely

    Sweely Well-Known Member

    Messages:
    1,467
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    165
    #2
    I've been working with wordpress for several years, and I'm pretty sure that I could help you out. All I ask for in return is that you explain your problem a bit better. One sentence is not enough.
     
    Sweely, Apr 4, 2010 IP
  3. tomcromp

    tomcromp Active Member

    Messages:
    454
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Last edited: Apr 4, 2010
    tomcromp, Apr 4, 2010 IP
  4. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #4
     <?php
     global $post;
     $myposts = get_posts('category=1');
     foreach($myposts as $post){
       echo '<a href="'.the_permalink().'">'.the_title().'</a><br>'
     }
     ?>
    Code (markup):
     
    javaongsan, Apr 4, 2010 IP
  5. tomcromp

    tomcromp Active Member

    Messages:
    454
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #5
    using that code i get tis error Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/.puffball/freeshituk/e2tv.tv/wp-content/themes/MovieSitePress/category-16.php on line 12
     
    tomcromp, Apr 5, 2010 IP
  6. tomcromp

    tomcromp Active Member

    Messages:
    454
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Fixed it their was a missing ; the problem is
    1. It does not link to the post but just shows the url
    2. Only has like 5 links needs them all.

    Cheers
    tom
     
    tomcromp, Apr 5, 2010 IP
  7. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #7
    sorry some missing codes

     <?php
    
     $myposts = get_posts('category=1&offset=1&numberposts=100');
     foreach($myposts as $post){
    	setup_postdata($post);
       echo '<a href="'.the_permalink().'">'.the_title().'</a><br>';
     }
     ?>
    Code (markup):
     
    javaongsan, Apr 5, 2010 IP
  8. tomcromp

    tomcromp Active Member

    Messages:
    454
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Ok http://www.e2tv.tv/category/90210/ you can see the code in action the the problem is that is shows the url rather than acutually linking to post. how would i do that?

    Cheers
    Tom
     
    Last edited: Apr 5, 2010
    tomcromp, Apr 5, 2010 IP
  9. tomcromp

    tomcromp Active Member

    Messages:
    454
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #9
    Can anyone help?
     
    tomcromp, Apr 5, 2010 IP
  10. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #10
    <?php
     global $post;
     $myposts = get_posts('category=4&offset=1&numberposts=100');
     foreach($myposts as $post){
    	setup_postdata($post);
       echo '<a href="';
       the_permalink();
       echo '">';
        the_title();
       echo '</a><br>';
     }
     ?>
    Code (markup):
     
    javaongsan, Apr 5, 2010 IP
  11. tomcromp

    tomcromp Active Member

    Messages:
    454
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #11
    Last edited: Apr 6, 2010
    tomcromp, Apr 6, 2010 IP
  12. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #12
    you can line them up by date if they are post in order
    &order=ASC&orderby=date or
    by title
    &order=ASC&orderby=title
    use tag to split the seasons
     
    javaongsan, Apr 6, 2010 IP
  13. tomcromp

    tomcromp Active Member

    Messages:
    454
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #13
    What you mean use tag to split the seasons.
    &order=ASC&orderby=date where would i put that in the code?

    Cheers
    Tom
     
    tomcromp, Apr 7, 2010 IP
  14. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #14
    $myposts = get_posts('category=4&offset=1&numberposts=100&order=ASC&orderby=date');
     
    javaongsan, Apr 7, 2010 IP
  15. tomcromp

    tomcromp Active Member

    Messages:
    454
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #15
    What you mean use tag to split the seasons? how? would i have to add tags to each episode?

    Cheers
    Tom
     
    tomcromp, Apr 7, 2010 IP