WordPress.org

Support

Support » How-To and Troubleshooting » More tag, get content with formatting: text wrap @ image

More tag, get content with formatting: text wrap @ image

  • Simple problem, I’ve seen three forum threads about this, but nothing that goes withthe basic codex w/o core hacks. Here’s the problem:
    I have a post, and in the post, BEFORE the MORE tag, there is an image, and 6 lines of text of the post wraps around the image which is floating left.

    I have the following code getting the picture and the first 6 lines, but no formatting, the text does NOT wrap around the image, which looks, well everybody knows how that looks.

    <?php
    global $post;
    $args = array( 'numberposts' => 1, 'offset'=> 0, 'category' => 6 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <p><?php echo apply_filters('the_content', _get_short_info($post->post_content)); ?></p>
    <?php endforeach; ?>

    Can anyone tell me what I need in that code that will get the formatting as well so the text wraps as well. BTW, I have this in the functions.php which defines the “_get_short_info” (not native to WP)

    function _get_short_info( $text ){
    	$t = explode('<!--more-->', $text);
    	return $t[0];
    }

    thanks,
    JSC

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi

    @esmi

    Forum Moderator

    Why don’t you just use <?php the_content();?>?

    <?php the_content();?> returns the entire post, not the content before the MORE tag. The problem with the text not wrapping around the image I just solved by putting the “alignleft” class into the style sheet, and styling it so the image behaves. Why it was wrapping in the post and nowhere else I don’t know, but now doesn’t matter.

    As far as the MORE tag problem goes, specifically, what’s in the HTML tab in the edit page for this post is:

    <a href="http://architekt-mm.de/wp-content/uploads/2011/05/sample1.jpg"></a><a href="http://architekt-mm.de/wp-content/uploads/2011/05/sample1.jpg">
    <img class="alignleft size-full wp-image-47" title="sample1" src="http://architekt-mm.de/wp-content/uploads/2011/05/sample1.jpg" alt="" width="150" height="100" /></a>Test post here for photo art. Test post here for photo art.Test post here for photo art.Test post here for photo art.Test post here for photo art.Test post here for photo art. <!--more-->

    That’s 7 sentences. The 8th sentence is “THIS IS AFTER THE MORE TAG/” – and that sentence is present on the page where I want just the content that comes AFTER the more tag. So that call <?php the_content();?> is printing the entire post, not the snippet before the tag.

    Any solution?
    thanks!
    JSC

    ooops, the post above doesn’t actually make sense, the last two sentences should read:
    The 8th sentence is “THIS IS AFTER THE MORE TAG/” – and that sentence is present on the page where I want just the content that comes BEFORE the more tag. So that call <?php the_content();?> is printing the entire post, not the snippet before the tag.

    Michael

    @alchymyth

    Forum Moderator

    <?php the_content();?> returns the entire post, not the content before the MORE tag.

    that depends on the setting of the variable $more:
    http://codex.wordpress.org/Customizing_the_Read_More

    and on the parameters in the_content():
    http://codex.wordpress.org/Function_Reference/the_content

    Cool, I will investigate these.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘More tag, get content with formatting: text wrap @ image’ is closed to new replies.
Skip to toolbar