• Resolved uaoh

    (@uaoh)


    Hi, I have a problem with the shortcode that takes the post title.

    The title is retrieved from a post in a CPT loop present on the same page, instead of the title of the post.

    The shortcode inserted in CF7 is this:
    [dynamichidden page-title “CF7_get_post_var key=’title'”]

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Hi @uaoh , I’d be happy to help!

    You can manually set the post ID in the built-in shortcode using the post_id attribute if you need to pull from a specific one like this:

    [dynamichidden page-title "CF7_get_post_var key='title' post_id='123'"]

    When a post ID is not provided (as is the case for most users), it tries to perform the lookup from the global $post object, and if that fails, then it uses get_the_ID() from the “the loop”

    But I’m guessing this contact form is inserted in a template that appears both on single.php and archive.php, so not ideal to create multiple forms for those instances. I’ll see what I can do ??

    Thread Starter uaoh

    (@uaoh)

    Hi, thanks for answering.

    Yes, the contact form is inserted in a template. In this case (a custom template). Please keep me updated.

    Mauro

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    So I know what the problem is and what the answer is, it’s just a matter of figuring out the best implementation method ??

    Problem: the shortcode is trying to get a post variable from an archive page

    Solution: use a shortcode that can automatically determine if the current page is a post or archive and then use the appropriate function to retrieve the title

    I’m currently writing a new built-in shortcode called CF7_get_current_var to do just that, so bear with me! When it’s done, you’ll be able to use this in the form builder:

    [dynamichidden page-title "CF7_get_current_var key='title'"]
    Thread Starter uaoh

    (@uaoh)

    Awesome, thank you!

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    This shortcode was added in version 3.4.0. Let me know how it works for you!

    Thread Starter uaoh

    (@uaoh)

    I tried on a copy of the page and it works! Thank you very much

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Wrong page title’ is closed to new replies.