[Support request] Elements

Home Forums Support [Support request] Elements

Home Forums Support Elements

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #830424
    Marco

    Hello
    tried to create a hook element with the following code but I’m getting some errors – hope somebody can help.

    Thanks

    <?php
    
    	global $post;
    
    	$pid = (int) $post->post_parent; 
    
    	echo do_shortcode('[ gallery id="'.$pid.'" numberposts="3" ]');
    ?>

    the error is as follows: Parse error: syntax error, unexpected 'gallery' (T_STRING), expecting ',' or ')' in /Users/Marco/Sites/cms/wp-mmjaeger/wp-content/plugins/generatepress-premium/elements/class-hooks.php(180) : eval()'d code on line 10

    #830804
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I just gave your code a try and didn’t get that error. Just to confirm, is “Execute PHP” checked?

    #830965
    Marco

    Execute PHP is checked – I’ve added the same element to the site online – gave you the url and credentials some days ago – same error?! maybe I’m doing something wrong?

    Parse error: syntax error, unexpected ‘gallery’ (T_STRING), expecting ‘,’ or ‘)’ in /home/mmjaeger/public_html/gp/wp-content/plugins/generatepress-premium/elements/class-hooks.php(180) : eval()’d code on line 7

    #830991
    Marco

    I put basically the same code into the functions.php file and it works fine?

    #831075
    Tom
    Lead Developer
    Lead Developer

    What about this?:

    <?php
        global $post;
    
        $pid = (int) $post->post_parent; 
    
        $shortcode = '[ gallery id="' . $pid . '" numberposts="3"]';
        echo do_shortcode( $shortcode );
    ?>

    Be sure to remove the space between the [ and gallery. I had to add the space to prevent our site from trying to render the shortcode.

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