0

How do I output the Gravity Forms "embed url" of a post type posted within a default post, in php, within a shortcode?

Does anyone know how to output these embed url merge tags on the frontend via php, within a shortcode? https://docs.gravityforms.com/embed_url/#usage

The form submit url is the same as the form output (creates post type) url.

I have added the hidden field containing the embed url and have given it a parameter name as shown in the screenshot https://i.imgur.com/NaFDxLm.png How do I call this parameter beside the post title, to replace the terms? and does it need to be declared, and where?

This is the shortcode in question

function myprefix_custom_grid_shortcode( $atts, $post_id ) {

    // Parse your shortcode settings with it's defaults
    $atts = shortcode_atts( array(

        'posts_per_page' => '-1',
        'term'           => ''
    ), $atts, 'myprefix_custom_grid' );
$user_id = userpro_get_view_user( get_query_var('up_username') );
    // Extract shortcode atributes
    extract( $atts );

    // Define output var
    $output = '';





    // Define query
    $query_args = array(
    'author'=> $user_id,
        'post_type'      => 'items', // Change this to the type of post you want to show
        'posts_per_page' => $posts_per_page,
    );

    // Query by term if defined
    if ( $term ) {

        $query_args['tax_query'] = array(
            array(
                'taxonomy' => 'category',
                'field'    => 'ID',
                'terms'    => $term,

            ),
        );

    }

    // Query posts
    $custom_query = new WP_Query( $query_args );

    // Add content if we found posts via our query
    if ( $custom_query->have_posts() ) {

        // Open div wrapper around loop
        $output .= '<div>';

        // Loop through posts
        while ( $custom_query->have_posts() ) {

            // Sets up post data so you can use functions like get_the_title(), get_permalink(), etc
            $custom_query->the_post();

            // This is the output for your entry so what you want to do for each post.
           // This is the output for your entry so what you want to do for each post.

$output .= '<div>' . esc_html( get_the_title() ) . get_the_term_list( $post_id, 'itemscategories', 'Posted in: ', ', ' ) . '</div>';
        }
        // Close div wrapper around loop
        $output .= '</div>';

        // Restore data
        wp_reset_postdata();

    }

    // Return your shortcode output
    return $output;

}
add_shortcode( 'myprefix_custom_grid', 'myprefix_custom_grid_shortcode' );

and the lines in question:

$output .= '<div>' . esc_html( get_the_title() ) . get_the_term_list( $post_id, 'itemscategories', 'Posted in: ', ', ' ) . '</div>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.