Okay
  Public Ticket #3741977
Global sections
Open

Comments

  • frank0080 started the conversation

    Hi everyone,

    I'm facing an issue with the default WooCommerce shop page, which doesn't allow me to add text below the products. To work around this, I used a Global section, but the problem is that it's now showing on all WooCommerce category pages. I only want this section to appear on the /shop/ page.

    I've temporarily hidden it from the category pages using CSS, but I'm concerned that this isn't the best long-term solution, especially in terms of SEO. Does anyone have suggestions on how I can limit this section to just the main shop page in WooCommerce?


    Your help us much appreciated!


    Best regards,


    Frank

  •  2,930
    Andrew replied

    Hi Frank,

    Thank you for reaching out to us.

    You can programmatically call global sections for specific locations via any advanced conditional logic by using the following method in your child theme functions.php:

    //ID of the global section e.g. 689.
    $global_section_id = '689';
    // $hook_location Hook location to output the global section. e.g. nectar_hook_after_footer_open
    // You can find the list in salient-core/includes/global-sections/display-options.php in set_settings
    $location_hook = 'nectar_hook_after_footer_open';
    add_action($location_hook, function() use ( $global_section_id, $location_hook ) {
        // slug of your page e.g. contact-page
       if( is_page('contact-page') ) {
          Nectar_Global_Sections_Render::get_instance()->output_global_section($global_section_id,$location_hook);
       }
    });
    

    Try this and let us know how it goes.

    Cheers,

  • frank0080 replied

    Hi Andrew,

    Thank you so much for your quick reply and for providing the code. I had my programmer add it, but he encountered a few issues. I've pasted his message below. Could you please take a look at his questions (1 to 3) to help us figure out where things are going wrong? Your help would be greatly appreciated!

    I have added the global section ID which is '2921', added the necessary hook called 'nectar_woocommerce_before_shop_loop', changed the page slug to 'shop' (tried with the page ID too) and also removed the "Display Locations" and "Display Conditions" options from the global section. Unfortunately, it doesn't work and I am sure that everything is setup correctly.

    I could only suggest to ask them:

    1. if the code is working fine;
    2. if there is something specific regarding the WooCommerce shop page we try to setup the section for;
    3. should we setup any "Display Locations" and "Display Conditions" so we could use this custom code.


    If there is anything else you need to know in order to answer my questions please let me know. Thanks in advance for your reply!

    Best regards,


    Frank

  •  2,930
    Andrew replied

    Hi Frank,

    Thanks for getting back to us. 

    To assist you better, we'd love to have a closer look at your setup and to do this, we'll need admin login credentials (dashboard URL, username, password) to your site. This will enable us to conduct a more in-depth investigation of the issue based on your specific configurations. Would you mind sharing this with us? I would also setting up a staging to avoid disrupting your live site as we troubleshoot this issue.

    If you prefer, you can safely share the access through an access plugin such as Controlled Admin Access.

    Before you provide this information, we strongly recommend taking a backup of your site.

    If you have any concerns or questions about this process, please don't hesitate to let me know.

    Best regards,