function.php 中的 Woocommerce + oceanwp 横幅配置
Woocommerce + oceanwp banner configuration in function.php
所以我的计划是简单地使用 functions.php 中的代码向所有页面添加自定义横幅,它有效,但不是我想要的
代码:
add_action( 'woocommerce_after_main_content', 'after_main_content', 1 );
function after_main_content() {
echo ' <style>
.img-container {
text-align: center;
}
</style>
<div class="img-container">
<img src="https://www.prospecs.lt/wp-content/uploads/2020/12/dpdtt-1.png" >
</div>
';
}
问题:
只有在带有侧边栏的页面中,我的横幅才被分配到另一个部分。
有什么想法可以将其放置在带有侧边栏的页面上的正确位置吗?
我的网站:www.prospecs.lt
我建议,您应该使用主题页脚操作。即:ocean_after_main 所以代码为:
add_action( 'ocean_after_main', 'after_main_content', 1 );
function after_main_content() {
if( is_shop() ){
echo ' <style>
.img-container {
text-align: center;
}
</style>
<div class="img-container">
<img src="https://www.prospecs.lt/wp-content/uploads/2020/12/dpdtt-1.png" >
</div>
';
}
}
所以我的计划是简单地使用 functions.php 中的代码向所有页面添加自定义横幅,它有效,但不是我想要的
代码:
add_action( 'woocommerce_after_main_content', 'after_main_content', 1 );
function after_main_content() {
echo ' <style>
.img-container {
text-align: center;
}
</style>
<div class="img-container">
<img src="https://www.prospecs.lt/wp-content/uploads/2020/12/dpdtt-1.png" >
</div>
';
}
问题:
只有在带有侧边栏的页面中,我的横幅才被分配到另一个部分。
我的网站:www.prospecs.lt
我建议,您应该使用主题页脚操作。即:ocean_after_main 所以代码为:
add_action( 'ocean_after_main', 'after_main_content', 1 );
function after_main_content() {
if( is_shop() ){
echo ' <style>
.img-container {
text-align: center;
}
</style>
<div class="img-container">
<img src="https://www.prospecs.lt/wp-content/uploads/2020/12/dpdtt-1.png" >
</div>
';
}
}