WordPress.org

Ready to get started?Download WordPress

Forums

Single.php not honoring the more link (12 posts)

  1. silencematters
    Member
    Posted 7 years ago #

    On single.php, I would like to have a collumn that displays the recent posts to the blog, and I need to for it to honor the <!--more--> link.
    It is not honoring the <!--more--> link because WP says - if Single = true, then dont display the <!--more--> link.

    anyone know how to get around this?

  2. josalmon
    Member
    Posted 7 years ago #

    Single.php is the file that displays one post in its entirety which is different to the content of index.php or the archive.php file for monthly or category archives.

  3. silencematters
    Member
    Posted 7 years ago #

    Right, I am aware of that. however, for design purposes, and trying to include a list of posts, with text in a collumn on the single/article view of the page.
    I am trying to see if that is possible.

  4. josalmon
    Member
    Posted 7 years ago #

    Do you mean links to the most recent posts?

  5. silencematters
    Member
    Posted 7 years ago #

    Well, on the single page, I have 2 collumns. One will have the full post and comments, the other will diaplay a list of posts just like the index.php.
    Date
    Title
    Content
    <!--more-->

    the prblem is that there is a function that is checking to see if the current page is single, and if so, dont use the more link.

    What I am getting, is a list of all the posts without honoring the <!--more--> link.

    I was just thinking that there might be a way to write a plugin that could handle this. maybe?

  6. vkaryl
    Member
    Posted 7 years ago #

    Why don't you just edit the function to say "false" instead of "true"? Of course, you'd have to keep track, since it would get overwritten next upgrade.

    Hmm. No, that probably wouldn't work - or if it did it's probably a lot more complicated than that. Wonder if you could just comment out that function?

    Or you could set up a new page template instead of using single.php....

  7. moshu
    Member
    Posted 7 years ago #

    Do those posts that should be in the "list" have anything in common?
    If yes, you could use a plugin like "related posts" or "in-series"...

  8. silencematters
    Member
    Posted 7 years ago #

    I have looked at using related posts - the prob is that it behaves slightly differently. It shows an excerpt instead of pulling the the list of posts along with the more link. I was hoping to get it to look as if there was a blog on one side, and the article on the other side.

  9. silencematters
    Member
    Posted 7 years ago #

    A new page template might work.... I need to sit and think about how that will fit in. I might have to go the route of using something like "recent posts" the probs with that is that it will not exclude the post that you are currently on.

    I thought it would be easiest to write a query that pulled the posts from the DB and out put all the posts except the one that is currently being displayed (as a full post in opposite collumn).

    I tried this - it worked, except for the fact that it was not honoring the more link.

    I will look into the page template. Maybe the function wont be triggered if it all happened on a page template.

  10. moshu
    Member
    Posted 7 years ago #

    "more" doesn't work on Pages either. So using a Page template (that will be recognized by WP as a Page...) won't really help.

  11. silencematters
    Member
    Posted 7 years ago #

    hmmm.
    Thanks.
    If I get the time, I might write a little plugin. I will let you know if I do.
    thanks again!

  12. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    I see your problem. You are on a single page but have a separate loop where you want more to be active.

    Add this to your code, just before your loop:
    function set_more($value) {
    global $more;
    $more = $value;
    }
    set_more(0);

    Setting the global $more to zero will force it to display the More link. Setting it to one will force it not to do so. So set it the way you want it to be just before your post loop and before your single post.

    Not the greatest solution, but it works.

Topic Closed

This topic has been closed to new replies.

About this Topic