我有以下几点很好用。。
elseif( get_post_type($post->ID) == \'press\' ){the_title_attribute();}
但是,我需要前面提到的标题用h2标记包装。尝试了这个,但它只是把h2放在标题后面。。。
elseif( get_post_type($post->ID) == \'press\' ){echo\'<h2>\'. the_title_attribute() .\'</h2>\';}
有什么想法吗?非常感谢您的帮助:)
我有以下几点很好用。。
elseif( get_post_type($post->ID) == \'press\' ){the_title_attribute();}
但是,我需要前面提到的标题用h2标记包装。尝试了这个,但它只是把h2放在标题后面。。。
elseif( get_post_type($post->ID) == \'press\' ){echo\'<h2>\'. the_title_attribute() .\'</h2>\';}
有什么想法吗?非常感谢您的帮助:)
这个the_title_attribute()
模板标记专门用于输出在锚标记中使用的格式化标题title
属性这个the_title()
和get_the_title()
模板标签用于标题的一般打印/显示。
我建议使用get_the_title()
, 而不是the_title_attribute()
. 也就是说:
elseif( get_post_type($post->ID) == \'press\' ){echo\'<h2>\'. get_the_title() .\'</h2>\';}
我认为这在语义上更为正确。这个the_title_attribute
函数已经回显,所以您无法回显它的值,请尝试此操作。
elseif( get_post_type($post->ID) == \'press\' ){ ?><h2><?php the_title_attribute(); ?></h2><?php }
或者,或者。。elseif( get_post_type($post->ID) == \'press\' ){ echo \'<h2>\'; the_title_attribute(); echo\'</h2>\'; }
或者:elseif( get_post_type($post->ID) == \'press\' ){ echo \'<h2>\' . the_title_attribute( \'\', \'\', false ) . \'</h2>\'; }
我有一个自定义页面,尝试更改页面标题函数将执行,但标题不会更改。这是我正在使用的代码: add_filter(\'wp_title\', set_page_title($brand)); function set_page_title($brand) { $title = \'Designer \'.$brand[\'name\'].\' - \'.get_bloginfo(\'name\'); //Here I can echo the resu