• Resolved ayeyebrazov

    (@ayeyebrazov)


    i wish to retrieve a page title, similar to what i get with

    [dynamictext inputname "CF7_get_post_var key='post_title'" post_id="123"]

    but using a dynamic post_id, example
    [dynamictext inputname “CF7_get_post_var key=’post_title'” post_id=”MY-DYNAMIC-VAR”]
    i get the dynamic post_id value via query string
    [CF7_GET key=’fid’]
    but i can’t find the way (or maybe the correct syntiax) to use this value, or a hidden-field value, in the post_id .

    anyone know if it’s possible?
    thank yuo very much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I understand what you’re asking. Unfortunately, none of our built-in shortcodes can do that since you’re looking to combine two, but here’s the code you can use to get what you need:

    function ayeyebrazov_get_title_by_id() {
    // Use DTX helper function to get the value of "fid" from $_GET
    $post_id = wpcf7dtx_get(array('key' => 'fid'));

    // Use DTX helper function to get the title of the post ID and return that
    return wpcf7dtx_get_post_var(array('key' => 'post_title', 'post_id' => $post_id ));
    }
    add_shortcode('ayeyebrazov_get_title_by_id', 'ayeyebrazov_get_title_by_id');

    And then in your form template, you can use your custom shortcode like this:

    [dynamic_text inputname "ayeyebrazov_get_title_by_id"]

    This code has not yet been tested as I wrote it directly in this reply ??

    Thread Starter ayeyebrazov

    (@ayeyebrazov)

    thank you very much;
    as a fast workaround, without php (deadlines!), in this case i resolved opening the form in a modal and retrieving the title in the simple way [CF7_get_post_var key=’post_title’ ] .
    but i’ll save this solution and test it for future needs.
    thanks for your support!

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Sounds great! My apologies for the delay, I totally understand deadlines. June is just a busy month for me—lots of volunteering at events!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get post title with dynamic ID’ is closed to new replies.