You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress后台显示短代码问题求助:前端正常后台出现et_pb_section内容

Fix: Prevent Shortcode from Showing in WordPress Admin

Got it, let's sort out this issue where your Elementor global module shortcode is showing up in the WordPress admin. Here's what's going wrong and how to fix it:

The Problem

Your current code doesn't distinguish between the frontend and admin area, and you're manually calling do_action('wp_footer')—this causes the hook to fire in the admin too, which outputs the shortcode content you don't want to see there.

The Solution

Modify your code to only run the output on the frontend, and remove the unnecessary manual hook call:

<?php
function cta_fixed() {
    // Only execute this on the frontend (not admin)
    if ( !is_admin() ) {
        echo do_shortcode('[et_pb_section global_module="2893"][/et_pb_section]');
    }
}
add_action( 'wp_footer', 'cta_fixed' );
// Remove the manual do_action call—WordPress triggers this hook automatically
?>

Key Changes Explained

  • !is_admin() Check: This conditional ensures your shortcode output only runs when the user is viewing the frontend of your site. The admin area will skip this code entirely.
  • Removed Manual do_action('wp_footer'): WordPress already fires the wp_footer hook at the correct point in the page lifecycle (both frontend and admin). Calling it manually forces an extra execution, which was part of why the shortcode showed up in the admin.

This tweak will keep your frontend working as expected while hiding the shortcode content from the WordPress admin.

内容的提问来源于stack exchange,提问作者Mark Hendriksen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:20:39