the_content filter issues
-
I am trying to use the_content tag in conjunction with the <!–main–> tag in post to extract certain amount of content from a post. The code below works fine, the main tag is respected and images are not shown:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1>” rel=”bookmark”><?php the_title(); ?></h1>
<img style=”float:left;margin:0px 10px 10px 0px;” src=”<?php echo get_post_meta($post->ID, “Blog”, true); ?>” alt=”alt text” /><div class=”blog”>
<?php
ob_start();the_content(“… continue reading ” .the_title(”, ”, false));
$postOutput = preg_replace(‘/<img[^>]+./’,”, ob_get_contents());
ob_end_clean();
echo $postOutput;
?>
The problem is that when I want to run a query on the post to display postings from certain categories, the post does not recognize the <!–main–> tag and displays the entire text of the post. Images are not displayed below as desired.
<?php $page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts(“showposts=10&paged=$page”); while ( have_posts() ) : the_post(); ?>
<h1>” rel=”bookmark”><?php the_title(); ?></h1>
<img style=”float:left;margin:0px 10px 10px 0px;” src=”<?php echo get_post_meta($post->ID, “Blog”, true); ?>” alt=”alt text” width=”400″ height=”251″/>
<div class=”blog”>
<?php
ob_start();the_content(“… continue reading ” .the_title(”, ”, false));
$postOutput = preg_replace(‘/<img[^>]+./’,”, ob_get_contents());
ob_end_clean();
echo $postOutput;
?>
The topic ‘the_content filter issues’ is closed to new replies.