WordPress.org

Ready to get started?Download WordPress

Forums

the_permalink (6 posts)

  1. Niemi
    Member
    Posted 7 years ago #

    Hello guys!

    I'm working on a project and I really need your help on this one. The achieve on any standard wordpress site shows all posts under a date. Now what can I do if i want it to show everything for only one specific category?

    If you see my site at http://www.kreativpotens.dk u'll notice that my theme shows a list of all post at the bottom-right. I want it to show ONLY all posts posted under this specific category http://www.kreativpotens.dk/?cat=2

    If i look in the sidebar.php this is the line i want to modify:

    <?php the_permalink() ?>">

    I suppose the_permalink has to be changed to something else, just don't know what to write.

    Can you help me?

  2. dannybcastillo
    Member
    Posted 7 years ago #

    <ul>
    <?php
    $myposts = get_posts('numberposts=5&category=1');
    foreach($myposts as $post) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> --- <?php the_excerpt(); ?></li>
    <?php endforeach; ?>
    </ul>

    Try this,

  3. dannybcastillo
    Member
    Posted 7 years ago #

  4. Niemi
    Member
    Posted 7 years ago #

    Thank you very much Danny!

    I forgot to say that i would like it to show only the Title of the posts, if I do it your way then it shows the whole post, which is kinda too much :D

    What should i change to only show the title?

  5. dannybcastillo
    Member
    Posted 7 years ago #

    --- <?php the_excerpt(); ?>
    just remove this from the code above. that should only show the title.

  6. Niemi
    Member
    Posted 7 years ago #

    Thank you Danny, truly you are the man of the night!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.