我在Wordpress上完成了我的网站的所有页面。
例如。
标题1:如何在Wordpress上建立网站
标题2:如何确保WP网站的安全
现在,我想将这一行添加到底部的所有页面中:
“如果您在页面标题上有任何问题,请在下面给出评论!”
我期待的结果应该是:
第1页内容:
第一步
第二步
如果你对如何在Wordpress上建立一个网站有任何疑问,请在下面给一个评论!
第2页内容
第一步
第二步
如果您对如何保护WP网站有任何疑问,请在下面给出评论!
我怎么能这么做?
发布于 2016-10-29 07:36:51
您可以通过the_content过滤器修改页面内容,请看下面的代码
add_filter( 'the_content', 'add_bottom_content' );
function add_bottom_content( $content ) {
$content .= "If you have any question on ".get_the_title().", please give a comment below!";
return $content;
}发布于 2016-10-29 07:32:31
您可以使用wp函数the_title()。
the_title(字符串$before = '',字符串$after = '',bool $echo = true ) 显示或检索具有可选内容的当前帖子标题。
参数#参数
$before (string) (可选)标题前面的内容。默认值:“” $after (string) (可选)附加到标题的内容。默认值:“” $echo (bool) (可选)默认为true.Whether以显示或返回。默认值: true
即:
the_title("If you have any question on ", ", please give a comment below!")发布于 2016-10-29 07:38:08
您可以在页面模板中添加一些php代码。
我以二十六个主题为例。在wp-content/themes/twentysixteen/template-parts/content-page.php中
在条目内容div中添加If you have any question on <?php the_title(); ?>, please give a comment below!。
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<?php twentysixteen_post_thumbnail(); ?>
<div class="entry-content">
<?php
the_content();
wp_link_pages( array(
'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentysixteen' ) . '</span>',
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
'pagelink' => '<span class="screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>%',
'separator' => '<span class="screen-reader-text">, </span>',
) );
?>
If you have any question on <?php the_title(); ?>, please give a comment below!
</div><!-- .entry-content -->
<?php
edit_post_link(
sprintf(
/* translators: %s: Name of current post */
__( 'Edit<span class="screen-reader-text"> "%s"</span>', 'twentysixteen' ),
get_the_title()
),
'<footer class="entry-footer"><span class="edit-link">',
'</span></footer><!-- .entry-footer -->'
);
?>
</article><!-- #post-## -->https://stackoverflow.com/questions/40316888
复制相似问题