[Support request] Strange text format after importing content using elements>>hooks

Home Forums Support Strange text format after importing content using elements>>hooks

  • This topic has 5 replies, 3 voices, and was last updated 6 months ago by Tom.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1117388
    S.A.

    Hi there,

    I use an element hook to import new posts. The content I am importing is a shortcode which looks like:

    [jsoncontentimporterpro url=yes url=https://someapiwithakey123abc&iata_code=<cf_wpcf-arrival-airport\> value&type=something]

    But after importing the content it shows:

    [jsoncontentimporterpro url=yes url=https://someapiwithakey123abc&iata_code= value&type=something]

    I don’t execute the shortcode in the element. Only the PHP. And when I run the same script outside of the element it imports the correct format/text.

    Any idea how I can fix this?

    #1117554
    David
    Staff
    Customer Support

    Hi there,

    you will need to check Execute Shortcode for it to work in a Hook Element.

    #1117568
    S.A.

    Tried it, but the script doesn’t execute and I see the following error message:

    Parse error: syntax error, unexpected 'alert' (T_STRING), expecting ')' in /www/wp-content/plugins/gp-premium 2/elements/class-hooks.php(180) : eval()'d code on line 71

    #1117569
    David
    Staff
    Customer Support
    #1117615
    S.A.

    Added the function, but in that case it already executes the shortcode and places the result in the post. It should place the shortcode in the post (without the strange formatting) so the shortcode can execute when a user visit the post. The result of the shortcode is dynamic.

    #1117676
    Tom
    Lead Developer
    Lead Developer

    Not too sure what you mean there – I assume you want the shortcode to execute on the frontend so something displays for the user?

    If so, have you tried this?:

    <?php echo do_shortcode( '[jsoncontentimporterpro url=yes url=https://someapiwithakey123abc&iata_code=<cf_wpcf-arrival-airport\> value&type=something]' ); ?>

    Then Execute PHP.

    If that doesn’t work, it’s possible that the formatting of the shortcode is throwing things off. You might need to use a manual hook, instead:

    add_action( 'generate_before_content', function() {
        echo do_shortcode( '[jsoncontentimporterpro url=yes url=https://someapiwithakey123abc&iata_code=<cf_wpcf-arrival-airport\> value&type=something]' );
    } );
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.