SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2011
    Posts
    31
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Wordpress & PHP Stuff

    Hi guys, i´ve knoledge of html/css/+-js and im just knew to wordpress&php stuff.

    Im building my own template and im having so much trouble finding the information i need...and i hope someone could give me a light, heres the deal:

    I wanna make a section of a page that filter the 5 most recent posts with categories of my wish.

    Example: in this section it will show the most 5 recent posts within the categories "food" and "restaurant". If theres none show a message and if theres more then 5 show a button like "show more" or something like that...

    I know there´s a PHP code for that and im searching, made some tries but i cant get it to work...

    Thank you already.

  2. #2
    SitePoint Zealot mike.fro's Avatar
    Join Date
    Jun 2005
    Location
    Lewisville, Texas
    Posts
    133
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by riner View Post
    Hi guys, i´ve knoledge of html/css/+-js and im just knew to wordpress&php stuff.Im building my own template and im having so much trouble finding the information i need...and i hope someone could give me a light, heres the deal:I wanna make a section of a page that filter the 5 most recent posts with categories of my wish.Example: in this section it will show the most 5 recent posts within the categories "food" and "restaurant". If theres none show a message and if theres more then 5 show a button like "show more" or something like that...I know there´s a PHP code for that and im searching, made some tries but i cant get it to work...Thank you already.
    Assuming you are using Wordpress here is some code that should do the trick. Replace category ID's with the ones you would like to be displayed though:

    <ul>
    <?php $recent = new WP_Query("cat=1&showposts=10"); while($recent->have_posts()) : $recent->the_post();?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark">
    <?php the_title(); ?>
    </a></li>
    <?php endwhile; ?>
    </ul>
    Michael John Froseth

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2011
    Posts
    31
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the fast reply @mike.fro but i want something a little more complicated, as my english fails i illustrated to show more accurately the idea!

    Here it is:

    teste2t.jpg

    Basically it wil show:

    1: The Mother Category (if ti has one).
    2: The Category.
    3: The Categorie description (it is already defined when the categorie was created).
    4: The posts that has both categories.

    =X little complicated...

  4. #4
    SitePoint Zealot mike.fro's Avatar
    Join Date
    Jun 2005
    Location
    Lewisville, Texas
    Posts
    133
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Something like this:

    <?php
    query_posts('showposts=5&cat=1');
    while(have_posts()) : the_post();
    ?>
    <ul>
    <li><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>

    <ul><li><?php the_excerpt(); ?></li>
    </ul>
    </li>
    </ul>
    <?php endwhile; ?>

    This may take some tweaking on your end. But it should be enough to get you started. Let me know if I provided the wrong solution... again, hehe =P

    Good Luck!
    Michael John Froseth

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2011
    Posts
    31
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    @mike.fro

    Thank you very much, i made it!!! Of course the project has several pages, it will need a lot of time but the codes are working!

    Cheers

  6. #6
    SitePoint Zealot mike.fro's Avatar
    Join Date
    Jun 2005
    Location
    Lewisville, Texas
    Posts
    133
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by riner View Post
    @mike.fro

    Thank you very much, i made it!!! Of course the project has several pages, it will need a lot of time but the codes are working!

    Cheers
    Yes, not a problem. Glad I could help. Like I said, it will take some customizing on your end to make it look however you'd like but the core is there for you to work with.

    Enjoy!
    Michael John Froseth

  7. #7
    SitePoint Enthusiast
    Join Date
    Dec 2011
    Posts
    31
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mike.fro View Post
    Yes, not a problem. Glad I could help. Like I said, it will take some customizing on your end to make it look however you'd like but the core is there for you to work with.

    Enjoy!
    Yeah i made it, its working all good, hehe.

    Thanks man.


Bookmarks

Posting Permissions

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