WordPress.org

Ready to get started?Download WordPress

Forums

More Tag (8 posts)

  1. akira01
    Member
    Posted 1 year ago #

    Hi,
    I would like have the following features in my blog. Hope the experts here can guide me with the script.

    I want the first 2 posts in home, page 2,4,5, so on, category page to have full articles (without "more" tag) and the rest of the posts with more tag automatically added at the place with 2 lines.

    Meaning that the first 2 posts, the reader doesn't need to click read more but the rest of the post in the page, they will have to click "read more". I have 10 posts in each page and category page.

    Please advise.

    Thanks in advance.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    general info:

    if you are using a standard loop, then try something like this within the loop (to replace the existing <?php the_content(); ?> or <?php the_excerpt(); ?> within the templates of the index page and archive pages (index.php, archive.php, category.php etc ...?):

    <?php if( $wp_query->current_post <= 1 ) :
    the_content();
    else :
    the_excerpt();
    endif; ?>
  3. akira01
    Member
    Posted 1 year ago #

    Hi Alchymyth,
    It doesn't work as what I want. Sorry, maybe my explanation is not clear enough. Let me elaborate the actual scenario.

    I have 10 posts in every page (front-page1, page2, page3 and so on). Each post will have 2 lines break that I intend to have the read more to show up. As such, I would like to modify the script to have only the first 2 posts in every page to show full posts and the rest of the 8 posts to show excerpt with "read more" at the 2 lines-break.

    In other word
    Page 1 - Post 1 and 2 = full article and post 3 to 10 = excerpt
    Page 2 - Post 11 & 12 - full article and post 13 to 20 = excerpt

    Please advise. Thanks in advance.

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    http://codex.wordpress.org/Function_Reference/the_content
    http://codex.wordpress.org/Function_Reference/the_content#Overriding_Archive.2FSingle_Page_Behavior

    possibly try:

    <?php if( $wp_query->current_post <= 1 ) :
    global $more; $more = 1;
    the_content();
    else :
    global $more; $more = 0;
    the_content('read more');
    endif; ?>
  5. akira01
    Member
    Posted 1 year ago #

    Hi alchymyth,
    It doesn't work. I've gone through the link you provide but it doesn't specify something like mine. I tried google and can't get an answer as well. If you or anyone here happen to come out with the code, please let me know.

    Thanks

  6. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    and the rest of the 8 posts to show excerpt with "read more" at the 2 lines-break.

    do you add the 'more tag' within the posts (when writing or editing them) ?

    this would be needed for the suggested code to work.

    - or is your question, how to automatically add a 'read-more' after two paragraphs?

  7. akira01
    Member
    Posted 1 year ago #

    Hi,
    No, I don't have the more tag added to all the 10 posts. I want the tag to be added automatically at the area with 2 line breaks.

    Thanks. Really appreciate for your valuable time to help me out.

  8. akira01
    Member
    Posted 1 year ago #

    Hi, by the way, your script posted earlier works if I add the more in every posts. No need to think of other code. I'll use the code you have provided earlier.

    Thank you so much for your help in solving my problem.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags