• Hi.

    I can’t display the BelingoGeo plugin on the site in header

    I use a third-party plugin to display Snippets and I write the following php code there:

    add_action( ‘ocean_top_bar_content’, ‘add_shortcode_to_top_bar’ );

    function add_shortcode_to_top_bar() {
    echo do_shortcode( ‘[belingogeo_selector show_question=”false”]’ );
    }

    But it doesn’t work. Nothing appears on the site. What could be the problem?

    p.s. WP+OceanWP+Elementor+WoodySnippet+RankMath

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hello @efimov2025,

    Thank you for reaching out,

    The main issue is that the hook ocean_top_bar_content you are trying to use does not exist in OceanWP, so the PHP code won’t have any effect.

    If you want to display your shortcode in the Top Bar, the easiest way is to simply paste the shortcode directly into the Top Bar Content field in the WordPress Customizer (WP Dashboard > Appearance > Customize > Top Bar). There is no need for custom PHP code for this: https://docs.oceanwp.org/article/900-customizer-top-bar

    However, if you want to add custom code using hooks, please note the correct hooks related to the Top Bar are (you can search them in OceanWP Docs):

    ocean_after_top_bar
    ocean_after_top_bar_inner
    ocean_before_top_bar
    ocean_before_top_bar_inner

    You can find more about using hooks here:
    https://docs.oceanwp.org/article/377-how-to-use-hooks
    https://docs.oceanwp.org/category/376-hooks

    I recommend using the shortcode inside the Customizer field first, as this is the intended way and simpler.

    Please let me know if you have any questions about the above steps.

    Hope it helps,
    Best Regards

Viewing 1 replies (of 1 total)

The topic ‘shortcode in Header’ is closed to new replies.