如何在PHP中更改行的位置?我正在尝试在woocommerce产品描述选项卡中添加自定义文本行。但这是账单的最后一笔。我想要这一页顶端的那行。我该怎么做呢?
我正在使用这个代码。
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;
}发布于 2021-07-23 04:22:18
$content .= $custom_content的意思是$content = $content . $custom_content;
如果我理解正确的话,你可能需要这个:
$content = $custom_content . $content;So,完整代码:
// 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;https://stackoverflow.com/questions/68490983
复制相似问题