我正在使用Wordpress制作一个网站,我必须为每个美国州制作五十页(例如domain.com/Alabama),我想键入一个变为“Alabama”的变量,对于每个州都是如此,所以我想要针对变量打印页面标题。 (例如,如果我在此页面上输入<h2>Services in {page_title}</h2>“domain.com/Alabama”,它应该给我“阿拉巴马州的服务”)
<h2>Services in {page_title}</h2>
我正在尝试这个get_the_title( int|WP_Post $post )
get_the_title( int|WP_Post $post )
我得到了空白......
如果你在循环中,你可以使用:
the_title();
https://codex.wordpress.org/Function_Reference/the_title