首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在PHP中更改行的位置?

如何在PHP中更改行的位置?
EN

Stack Overflow用户
提问于 2021-07-23 04:13:21
回答 1查看 38关注 0票数 0

如何在PHP中更改行的位置?我正在尝试在woocommerce产品描述选项卡中添加自定义文本行。但这是账单的最后一笔。我想要这一页顶端的那行。我该怎么做呢?

我正在使用这个代码。

代码语言:javascript
复制
add_filter( 'the_content', 'customizing_woocommerce_description' );
function customizing_woocommerce_description( $content ) {
    // Only for single product pages (woocommerce)
    if ( is_product() ) {

        // The custom content
        $custom_content = '<p class="custom-content">' . __("This is the last line in the description", "woocommerce").'</p>';

        // Inserting the custom content at the end
        $content .= $custom_content;
    }
    return $content;
}
EN

回答 1

Stack Overflow用户

发布于 2021-07-23 04:22:18

$content .= $custom_content的意思是$content = $content . $custom_content;

如果我理解正确的话,你可能需要这个:

代码语言:javascript
复制
$content = $custom_content . $content;

So,完整代码:

代码语言:javascript
复制
// Only for single product pages (woocommerce)
if ( is_product() ) {

    // The custom content
    $custom_content = '<p class="custom-content">' . __("This is the last line in the description", "woocommerce").'</p>';

    // Inserting the custom content at the end
    $content = $custom_content . $content;
}
return $content;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68490983

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档