admin管理员组文章数量:1023511
The following code works great.
I would just like to know if it is correct to have two 'If' Statements like I have done?
(The purpose of this snippet is to replace the generic "Category, Tag" and replace with custom text).
add_filter( 'get_the_archive_title', 'my_theme_archive_title' );
/**
* Remove archive labels.
*
* @param string $title Current archive title to be displayed.
* @return string Modified archive title to be displayed.
*/
function my_theme_archive_title( $title ) {
if ( is_tax('us_state') ) {
$title = single_term_title( 'Conferences In ', false );
}
if ( is_tax('country') ) {
$title = single_term_title( 'CConferences In ', false );
}
return $title;
}
Also - what is the false statement at the end for? Is it stating whether JQuery needs to be loaded?
Thanks for all feedback - I just want to make sure I am doing it correctly.
The following code works great.
I would just like to know if it is correct to have two 'If' Statements like I have done?
(The purpose of this snippet is to replace the generic "Category, Tag" and replace with custom text).
add_filter( 'get_the_archive_title', 'my_theme_archive_title' );
/**
* Remove archive labels.
*
* @param string $title Current archive title to be displayed.
* @return string Modified archive title to be displayed.
*/
function my_theme_archive_title( $title ) {
if ( is_tax('us_state') ) {
$title = single_term_title( 'Conferences In ', false );
}
if ( is_tax('country') ) {
$title = single_term_title( 'CConferences In ', false );
}
return $title;
}
Also - what is the false statement at the end for? Is it stating whether JQuery needs to be loaded?
Thanks for all feedback - I just want to make sure I am doing it correctly.
Share Improve this question asked May 5, 2019 at 23:07 HenryHenry 9831 gold badge8 silver badges31 bronze badges1 Answer
Reset to default -1You should use elseif for the second if statement:
$title1 = single_term_title( 'Conferences In ', false );
$title2 = single_term_title( 'CConferences In ', false );
add_filter( 'get_the_archive_title', 'my_theme_archive_title' );
function my_theme_archive_title( $title ) {
if ( is_tax('us_state') ) {
$title1;
}
elseif ( is_tax('country') ) {
$title2;
}
else {
return $title;
}
}
You can read here about true/false https://developer.wordpress/reference/functions/single_term_title/
The following code works great.
I would just like to know if it is correct to have two 'If' Statements like I have done?
(The purpose of this snippet is to replace the generic "Category, Tag" and replace with custom text).
add_filter( 'get_the_archive_title', 'my_theme_archive_title' );
/**
* Remove archive labels.
*
* @param string $title Current archive title to be displayed.
* @return string Modified archive title to be displayed.
*/
function my_theme_archive_title( $title ) {
if ( is_tax('us_state') ) {
$title = single_term_title( 'Conferences In ', false );
}
if ( is_tax('country') ) {
$title = single_term_title( 'CConferences In ', false );
}
return $title;
}
Also - what is the false statement at the end for? Is it stating whether JQuery needs to be loaded?
Thanks for all feedback - I just want to make sure I am doing it correctly.
The following code works great.
I would just like to know if it is correct to have two 'If' Statements like I have done?
(The purpose of this snippet is to replace the generic "Category, Tag" and replace with custom text).
add_filter( 'get_the_archive_title', 'my_theme_archive_title' );
/**
* Remove archive labels.
*
* @param string $title Current archive title to be displayed.
* @return string Modified archive title to be displayed.
*/
function my_theme_archive_title( $title ) {
if ( is_tax('us_state') ) {
$title = single_term_title( 'Conferences In ', false );
}
if ( is_tax('country') ) {
$title = single_term_title( 'CConferences In ', false );
}
return $title;
}
Also - what is the false statement at the end for? Is it stating whether JQuery needs to be loaded?
Thanks for all feedback - I just want to make sure I am doing it correctly.
Share Improve this question asked May 5, 2019 at 23:07 HenryHenry 9831 gold badge8 silver badges31 bronze badges1 Answer
Reset to default -1You should use elseif for the second if statement:
$title1 = single_term_title( 'Conferences In ', false );
$title2 = single_term_title( 'CConferences In ', false );
add_filter( 'get_the_archive_title', 'my_theme_archive_title' );
function my_theme_archive_title( $title ) {
if ( is_tax('us_state') ) {
$title1;
}
elseif ( is_tax('country') ) {
$title2;
}
else {
return $title;
}
}
You can read here about true/false https://developer.wordpress/reference/functions/single_term_title/
本文标签: Two 39If Statements39 is my syntax correct (functionsphp) and what is 39false39
版权声明:本文标题:Two 'If Statements' is my syntax correct (functions.php) and what is 'false' 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745521899a2154351.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论