Black Friday Sale! Get up to $40 off GP Premium!Learn more

[Resolved] Do Shortcode in 404 Template

Home Forums Support Do Shortcode in 404 Template

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #476171
    Sebastian

    Hellö!

    So I’m using the code to alter the display on the 404 page and want to load a gravityforms form there. So I would think the code should look something like this, but since it’s not a post or page the shortcode won’t just render the form like that.
    So what do I need to add to have the shortcode rendered, please?

    add_filter( 'generate_404_text','generate_custom_404_text' );
    function generate_custom_404_text()
    {
          return '[gravityform id="3" title="false" description="false"]';
    }
    GeneratePress 2.0.2
    GP Premium 1.5.6
    #476449
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try this:

    add_filter( 'generate_404_text', 'tu_custom_404_text' );
    function tu_custom_404_text() {
          return do_shortcode( '[gravityform id="3" title="false" description="false"]' );
    }
    #476461
    Sebastian

    aaaaand it works. 🙂
    thank you so much.

    #476463
    Tom
    Lead Developer
    Lead Developer
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.