在 php/wordpress 中打印时如何从文本中删除锚标记

发布于 2024-12-01 18:07:23 字数 1522 浏览 1 评论 0原文

我试图弄清楚如何删除将打印单词包装到 html 页面的锚标记。 Suchas:

<a href="something">blog</a>

相反,简单地说:

blog

我认为这与这两者有关:

%1$s

并且主要与我的代码的这一部分有关:

    // Prints the string, replacing the placeholders.
    printf(
        $posted_in,
        get_the_category_list( ', ' ),
        $tag_list,
        get_permalink(),
        the_title_attribute( 'echo=0' )
    );

我创建了一个新函数。

现在只是想弄清楚为什么 %1$s 生成类别名称的锚标记版本而不是纯文本格式?

我认为这也部分与此有关: = __

不太确定。因为正常的类别引用:%s 也无法代替 %1$s

if ( ! function_exists( 'designconcepts_posted_under' ) ) :
/**
 * Prints HTML with title information for the current single post (category title).
 *
 * @since Design Concepts 1.0
 */
function designconcepts_posted_under() {
    // Retrieves tag list of current post, separated by commas.
    $tag_list = get_the_tag_list( '', ', ' );
    if ( $tag_list ) {
        $posted_in = __( '%1$s', 'designconcepts' );
    } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
        $posted_in = __( '%1$s', 'designconcepts' );
    } else {
        $posted_in = __( '%1$s', 'designconcepts' );
    }
    // Prints the string, replacing the placeholders.
    printf(
        $posted_in,
        get_the_category_list( ', ' ),
        $tag_list,
        get_permalink(),
        the_title_attribute( 'echo=0' )
    );
}
endif;

I'm trying to figure out how tor remove the anchor tag that wraps a printed word to the html page. Suchas:

<a href="something">blog</a>

instead to be just simply:

blog

I reckon it has something to do with both this:

%1$s

and mostly this part of my code:

    // Prints the string, replacing the placeholders.
    printf(
        $posted_in,
        get_the_category_list( ', ' ),
        $tag_list,
        get_permalink(),
        the_title_attribute( 'echo=0' )
    );

I made a new function.

Now just trying to figure out why %1$s produces the anchor tag version of the category name instead of just the plain text format instead?

I'm thinking it partly has to do with this as well: = __

Not too sure. Cause the normal Category reference: %s does not work either in place of %1$s.

if ( ! function_exists( 'designconcepts_posted_under' ) ) :
/**
 * Prints HTML with title information for the current single post (category title).
 *
 * @since Design Concepts 1.0
 */
function designconcepts_posted_under() {
    // Retrieves tag list of current post, separated by commas.
    $tag_list = get_the_tag_list( '', ', ' );
    if ( $tag_list ) {
        $posted_in = __( '%1$s', 'designconcepts' );
    } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
        $posted_in = __( '%1$s', 'designconcepts' );
    } else {
        $posted_in = __( '%1$s', 'designconcepts' );
    }
    // Prints the string, replacing the placeholders.
    printf(
        $posted_in,
        get_the_category_list( ', ' ),
        $tag_list,
        get_permalink(),
        the_title_attribute( 'echo=0' )
    );
}
endif;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文