WordPress.org

Ready to get started?Download WordPress

Forums

send text after "more" tag to specific div (3 posts)

  1. svsdnb
    Member
    Posted 1 year ago #

    I have built a custom theme and was wondering if there is a way for the text of the page prior to the more tag to go to one div and the text after the more tag to go to another div - both on the same page just different areas of the page.

    I am trying to this so that I'm not creating 50 "custom" templates (one for each page).

    As of now, I have to set up a template per page. Put the text and images I want in section A in the page post and the text and images I want in section B are hardcoded into the template file.

    This is less than ideal.

    Thank you.

  2. svsdnb
    Member
    Posted 1 year ago #

    Since you can wrap the more tag with scr mark up or a span class for styling with in functions.php could I feasibly wrap it in a div tag as well? Is that still a practice used with the current word press version?

    I found this from 2010 - http://digwp.com/2010/01/wordpress-more-tag-tricks/ - which gave me the idea.

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

    look closely at the the_content() function;

    http://codex.wordpress.org/Function_Reference/the_content

    particluar the use of the $stripteaser parameter; and the influence of the $more variable.
    http://codex.wordpress.org/Function_Reference/the_content#Overriding_Archive.2FSingle_Page_Behavior

    you also need to check if the more tag is used at all;

    example:

    <?php //check for the more tag//
    if( strpos( get_the_content(), '<span id="more-' ) ) { ?>
    	<div class="pre-more">
    	<?php global $more; $more = 0; the_content('', true); $more = 1; ?>
    	</div>
    	<div class="post-more">
    	<?php the_content('', true); ?>
    	</div>
    <?php } else { ?>
    	<div class="no-more">
    	<?php the_content(); ?>
    	</div>
    <?php } ?>

    you possibly also need to do:
    http://codex.wordpress.org/Customizing_the_Read_More#Prevent_Page_Scroll_When_Clicking_the_More_Link

Topic Closed

This topic has been closed to new replies.

About this Topic