【问题标题】:Changing category links to point to '#' instead of category将类别链接更改为指向“#”而不是类别
【发布时间】:2016-12-12 23:52:42
【问题描述】:

我似乎无法正确调整以下代码以将类别链接指向“#”而不是指向类别页面。任何建议将不胜感激!

if ( ! function_exists( 'theme_framework_post_cat' ) ) :
function theme_framework_post_cat() {
  if ( 'post' == get_post_type() ) {
    $categories_list = get_the_category_list( esc_html__( ', ', 'theme' ) );
    if ( $categories_list && theme_framework_categorized_blog() ) {
        printf( '<span class="cat-links">' . esc_html__( '%1$s', 'theme' ) . '</span>', $categories_list );
    }
  }
}
endif;

【问题讨论】:

    标签: php html wordpress tags meta-tags


    【解决方案1】:

    你可以试试:

    $categories_list = strip_tags(get_the_category_list( esc_html__( ', ', 'theme' ) ));
    

    strip_tags() 是一个 PHP 函数,它将删除 get_the_category_list WP 函数返回的所有标签。

    【讨论】:

    • 这使得它们不是链接。你想用它们作为链接做其他事情吗?
    • 让它们不是链接,而只是类别的名称实际上是更好的主意。非常感谢!!!
    猜你喜欢
    • 2013-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-14
    • 2018-05-12
    • 2016-07-17
    • 1970-01-01
    相关资源
    最近更新 更多