anything i put after
<div class='article-content'>
displays as a text on the front end instead of calling up the original post title
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
$posts = get_field('show_post_in_content_part',$postID); if( $posts ):
$category_detail=get_the_category($postID);
foreach($category_detail as $cd){
$cat=$cd->cat_name;
}
foreach( $posts as $post): setup_postdata($post);
$img = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
$link=get_the_permalink($post->ID);
$cn = $post->post_excerpt;
$contenta=implode(' ', array_slice(explode(' ', $cn), 0, 32));
$contentm=implode(' ', array_slice(explode(' ', $cn), 0, 15));
$ad_code = "<div class='article-block cf'>
<div class='triangle-02'>
<!--<img src='".$img."' alt=''>-->
</div>
<div class='article-content'>
<h3><div class= 'article-title'></h3>
<p class='desktop_view'>".$contenta."</p>
<p class='mobile'>".$contentm."</p>
<p><a href='".$link."' class='readmore'>read more..</a></p>
</div>
<div class='article-img'>
<div class='img'>
<img src='".$img."'>
<div class='caption'>".$cat."</div>
</div>
</div>
</div>";
endforeach; wp_reset_postdata(); endif;
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );
}
return $content;
}
anything i put after
<div class='article-content'>
displays as a text on the front end instead of calling up the original post title
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
$posts = get_field('show_post_in_content_part',$postID); if( $posts ):
$category_detail=get_the_category($postID);
foreach($category_detail as $cd){
$cat=$cd->cat_name;
}
foreach( $posts as $post): setup_postdata($post);
$img = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
$link=get_the_permalink($post->ID);
$cn = $post->post_excerpt;
$contenta=implode(' ', array_slice(explode(' ', $cn), 0, 32));
$contentm=implode(' ', array_slice(explode(' ', $cn), 0, 15));
$ad_code = "<div class='article-block cf'>
<div class='triangle-02'>
<!--<img src='".$img."' alt=''>-->
</div>
<div class='article-content'>
<h3><div class= 'article-title'></h3>
<p class='desktop_view'>".$contenta."</p>
<p class='mobile'>".$contentm."</p>
<p><a href='".$link."' class='readmore'>read more..</a></p>
</div>
<div class='article-img'>
<div class='img'>
<img src='".$img."'>
<div class='caption'>".$cat."</div>
</div>
</div>
</div>";
endforeach; wp_reset_postdata(); endif;
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );
}
return $content;
}
Share
Improve this question
edited Sep 9, 2019 at 0:35
Jacob Peattie
44.2k10 gold badges50 silver badges64 bronze badges
asked Sep 8, 2019 at 13:11
KUNLE RICHARDKUNLE RICHARD
1
1 Answer
Reset to default 0I don't see you closed your <div class='article-content'>
element. That is probably the issue. Also, it is empty, there is nothing 'inside' that div
.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745174700a4615131.html
评论列表(0条)