[resolved] Mini-loop adding pages (5 posts)

  1. leanda
    Posted 9 years ago #


    I've set up a static page which uses a mini-loop to pull in recent posts into a sidebar.

    Here's the code:

    $news=$wpdb->get_results("SELECT ID, post_title, post_excerpt FROM $wpdb->posts
    WHERE post_status='publish' ORDER BY ID DESC LIMIT $how_many");
    foreach($news as $np){
    echo '

    If I add a new page it also brings in the page by ID and puts a link in the middle of my recent posts list. Is there any way to stop it from doing this?

    This is the first time I've used PHP so I'm really struggling.


  2. moshu
    Posted 9 years ago #

  3. leanda
    Posted 9 years ago #

    Thanks! You have no idea how grateful I am for your help. It worked!!!

    You wouldn't also happen to know I can add a permalink to the bottom of a post excerpt that says something like 'Read More...". I know the post_title does this but I also want to add a "Read more" link at the bottom of the excerpt.

    Thanks so much!

  4. moshu
    Posted 9 years ago #

    "more" and the_excerpt are TWO (2) different techniques to... shorten(?), cut your content.

    "more" is added manually where you want the break, while writing the post - the_excerpt works on its own.

    You can customize the "more" just by editing your template files:

    For a "custom" excerpt, you need a plugin:

  5. leanda
    Posted 9 years ago #

    Thanks! I've had a quick look and it looks like it will do what I need.

    Thanks so much for your help, I really appreciate it.

Topic Closed

This topic has been closed to new replies.

About this Topic