Can you clarify what you mean by “rewrited by two”? Can you post a link to a page that shows the issue?
Thread Starter
nahp
(@nahp)
Thank you for support.
I can tell you in other way. I put a <!–more–> in WordPress. and when I got to the website, the entire article is visible and the <!–more–> is erased. you can only see two
one above the other where the tag was…
Thread Starter
nahp
(@nahp)
Reading some other forums, the problem could come from my theme… I changed theme and … the “read more” works fine. Then, I’m sure I made a mistake…
For example I’m looking for use only one article and I made it like this :
<?php
$id = 57;
$billet = get_post($id);
$title = $billet->post_title;
$date = $billet->post_date;
$contenu = $billet->post_content;
$contenu = apply_filters('the_content', $contenu);
$contenu = str_replace(']]>', ']]>', $contenu);
?>
<h5 class="title hbold"><?php echo "$title"; ?></h5>
<p><?php echo "$contenu"; ?></p>
When you call the_content(), WordPress does some regex matching behind the scenes to see if the <!--more--> tag exists and does the right thing if it does. As you’ve seen, directly outputting the post content like you’re doing bypasses the matching. One thing you could do would be to call setup_postdata() to set up the global $post object so the_content() will work:
<?php
$id = 57;
$post = get_post( $id );
setup_postdata( $post );
?>
<h5 class="title hbold"><?php the_title(); ?></h5>
<p><?php the_content(); ?></p>
<?php wp_reset_postdata(); ?>
Some caveats: You must assign the output of get_post() to a variable named $post, and the exact name matters. You also have to call wp_reset_postdata() so that other pages aren’t affected.
Thread Starter
nahp
(@nahp)
Thank you so much. it works.