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

  1. svsdnb
    Posted 2 years 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
    Posted 2 years 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. Michael
    Part-Time Forum Moderator
    Posted 2 years ago #

    look closely at the the_content() function;


    particluar the use of the $stripteaser parameter; and the influence of the $more variable.

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


    <?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 class="post-more">
    	<?php the_content('', true); ?>
    <?php } else { ?>
    	<div class="no-more">
    	<?php the_content(); ?>
    <?php } ?>

    you possibly also need to do:

Topic Closed

This topic has been closed to new replies.

About this Topic