【发布时间】:2019-07-16 15:28:56
【问题描述】:
在主题中有两个文件:
single.php
f-template.php→ 用于默认帖子类型。它有不同的设计。
Home.php 将获取前 10 个帖子,它们可以在上述任何模板中。
但是,需要的是 home.php 上的内容来自f-template.php
那么这两个东西应该在home.php上实现
function folder_paragrapgh($content){
return preg_replace('/<p([^>]+)?>/', '<p class="para para2">', $content);
}
add_filter('the_content', 'folder_paragrapgh');
和
<script>
(function($) {
// do all your $ based jquery in here.
$(function() {
$('p.class2').prepend('<img src="http:/sample.com/img/folder.svg" width="50" height="25" alt="">');
});
})(jQuery);
</script>
我试过这个:
if( is_page_template( 'f-template.php' ) ) {
function folder_paragrapgh($content){
return preg_replace('/<p([^>]+)?>/', '<p class="para para2">', $content);
}
add_filter('the_content', 'folder_paragrapgh');
}
the_content();
}
但这没有用。实际上它是有缺陷的,因为我们正在处理的模板是home.php。
那么我们有任何解决方案来实现我们想要实现的目标吗?
【问题讨论】: