admin管理员组文章数量:1414621
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
.
本文标签: How do i call up default post title in custom posts
版权声明:本文标题:How do i call up default post title in custom posts 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745174700a2646178.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论