[Resolved] do shortcode not working before entry title

Home Forums Support [Resolved] do shortcode not working before entry title

Home Forums Support do shortcode not working before entry title

  • This topic has 2 replies, 2 voices, and was last updated 3 months ago by David.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2221042
    rikdol

    i’m using metaslider that produces a shortcode to display a slider.

    using Elements > hooks

    i’ve created a hook on generate_before_entry_title and checked shortcodes + php
    also added a simple echo to see it show up.

    <?php 
    add_action( 'generate_before_entry_title', function() {
        do_shortcode('[metaslider id="212"]');
        echo "kenobi";
    } );
    ?>

    also tried without the add_action:

    <?php 
        do_shortcode('[metaslider id="212"]');
    ?>

    But it won’t show up, even with display rules set to ‘homepage’ or ‘everywhere’

    #2221083
    rikdol

    My problem was using a wrong hook it seems. after googling on different topic i came by : https://docs.generatepress.com/article/hooks-visual-guide/

    Which helped me pick a different hook at the location i was trying to add it to.

    solved.

    #2221091
    David
    Staff
    Customer Support

    Hi there,

    if you use a Hook Element:

    https://docs.generatepress.com/article/hooks-element-overview/

    Then:

    1. Just add the shortcode: [metaslider id="212"] to the text area.
    2. Check the Execute Shortcode option.
    3. Set the Hook to where you require it*
    4. Set the Display Rules > Location to where you need it eg. if you want the Home Page then the location is Front Page

    * The hooks vary on what page you’re viewing. For example the: generate_before_entry_title only exists on a Post not a static page. Instead try the generate_before_content hook.
    See here for the common hooks:

    https://docs.generatepress.com/article/hooks-visual-guide/

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.