post fields from one custom post type into another

Wondering if there's a way to have two custom post types and insert shortcodes that pull fields from one custom post type into the text editor field of another custom post type? Trying to very cleverly arrange complex, repeating content and this would solve a number of problems for us.

Looked at the shortcodes and did a test but couldn't figure out how to do it (if its possible at all.)

  • Adam Czajczyk

    Hey Peter,

    I hope you're well today and thank you for your question!

    I can see what you wish to achieve here but I think you'll have to dig a little bit deeper and there'll be some template work required. If you aren't using a custom WP theme (or you haven't already customized one by creating a child theme) it would be best to create a child theme of your current WP theme first:

    In your child theme create a template for your custom post type and then you may try to go this way:

    1) use the shortcode with a do_shortcode() WP function, e.g.

    $my_shortcode = "[custom_fields_input post_id='post_id'] [ct_filter terms='cat1, cat2,..'] _ct_selectbox_4cf582bd61fa4, _ct_text_4cfeb3eac6f1f,... [/ct_filter] [/custom_fields_input];
    echo do_shortcode($my_shortcode);

    2) assuming you wish to pull value for "post_id" with another shortcode, try this:

    $my_post_id = do_shortcode("[shortcode_that_pulls_id]");
    $my_shortcode = "[custom_fields_input post_id=' . $my_post_id. '] [ct_filter terms='cat1, cat2,..'] _ct_selectbox_4cf582bd61fa4, _ct_text_4cfeb3eac6f1f,... [/ct_filter] [/custom_fields_input];
    echo do_shortcode($my_shortcode);

    Generally, this is the best way to deal with nested shortcodes mixed with dynamically pulled values.

    I hope that helps!


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.