Site logo

Archived topic

Nested Shortcode in Page Header.

12 replies · Started by Emran on July 29, 2017

Viewing posts 1–13 of 13

My setup is EL+Pro+GP+GPP.

I made 2 template in Elementor LIbrary. Then added those shortcode to slider content. When the slider template added directly to Page, it works. But when I added it IN Page Header (GPP 1.4 rc1), it only execute first level shortcode.

How I able to solve that??

Page Header -> [slider template] -> [slide 1 Template] & [slide 2 Template]

In this format, slide 1 and slide 2 template are not working.

Demo URL: http://50.28.105.70/~toassess/

Here same slider template added as Page Header and below page header.

Emranul Hassan

Hi there,

So if the slider shortcode is added into the page header, and the slider shortcode has an Elementor shortcode, the Elementor shortcode doesn't execute?

Thanks Tom for quick reply.

Slider Shortcode executed properly. But In each slide, I added elementor shortcode as content, which do not execute.
Here is the image for your reference.
Individual Slide of Elementor SLider Element

Here is Source Code, where shortcode placed in individual slide do not execute properly.
Not executed Shortcode of Individual Slide

If you require, I can give you wp-admin access.

Emran.

This might be an issue with the Elementor text field not executing shortcodes. Have you checked with their support?

Thanks for your reply.

I tested same slider shortcode in Elementor Shortcode Element and Text Editor Element. It works perfectly.

But when I add same shortcode in Page Header and GP Hooks, it only execute first level Shortcode, nested shortcode do not executed.

Any suggestion?

Emranul Hassan

I'm not really seeing how the Page Header is coming into play within the above scenario? I see an Elementor shortcode inside a Slides field inside Elementor. When does Page Header enter the picture?

From a coding perspective, the content inside the Page Header is ran through the do_shortcode() WP function - that's the core way of executing shortcodes.

I wanted to make that Slider as Page Header in Homepage, so that I can do some customization on Navigation and to make Navigation over the Slider.

It also not works in GP Hooks.

I can do that in different way, adding elementor section below navigation then adding negative margin and navigation background as transparent. But then I am missing lots of customization you offer in Page Header for Navigation color/background etc.

I think, I am unable to make the scenario clear to you. If wp-admin access helps you to understand better, I can provide you admin access.

Actually I made it work adding a Filter Hook in your Page-Header.php and additional filter to do do_shortcode of Header COntent.

Page-header.php

So please inform us, what filter you use to output content of page header. It will solve my issue.

Thanks.
Emranul Hassan.

What's the iwebw_additional_shortcode filter?

If you look lower to where the content is out, it's wrapped in the do_shortcode() filter. According to WP, that's all that needs to be done in order to execute shortcodes.

iwebw_additional_shortcode I just experimenting some alternatives to solve my issue.

Yes. I saw the code has do_shortcode filter wrapped in $options['content'].

My situation is like [shortcode1] some content [shortcode2] some content [/shortcode1].

Everytime, shortcode1 is executed, but shortcode2 is not executed.

So I need to pass the content of shortcode1, one additional do_shortcode filter to execute shortcode2.

Sp please could you please tell me how I can hook into page header content, specially $options['content'], so that I can add additional filter to get my desired output.

What you're trying to do isn't something I imagined would be necessary at any point, so I'm not 100% sure it's even possible.

One possible solution:

add_filter( 'generate_page_header_options', 'tu_alter_page_header_content' );
function tu_alter_page_header_content( $options ) {
    $options['content'] = apply_filters( 'iwebw_additional_shortcode', $options['content'] );
    return $options;
}

Thanks for your support.

1. I deleted the additional line of code I added in page-header.php.
2. I added the following modified code as per your suggestion and it works fine

add_filter( 'generate_page_header_options', 'tu_alter_page_header_content' );
function tu_alter_page_header_content( $options ) {
    $options['content'] = do_shortcode( $options['content'] );
    return $options;
}

Thanks. Have a nice day.

Very strange as the code does that for you anyways on output.

Either way, glad it's working for you now :)

This archived topic is closed to new replies.