Shortcode in Custom Post Type

I am creating surveys using another plugin...and the shortcode is used for a survey to be placed in custom post type. What i want to know if its possible to automate shortcode in a custom post type, so, when a survey is created, it will be generated a new post in the custom post type

  • Katya Tsihotska
    • Support & QA

    Hi Amit

    I trust you're well today!

    Since this is dealing with more advanced coding topics, I'm going to ping our SLS Team (code experts) to get their valuable feedback on this issue. One of our SLS members will reply back here as soon as more information is available.

    Please keep in mind that our SLS Team deals with more complicated issues, thus it may take a little longer for them to reply here. Thank you for your patience while we look into this further.

    Kind regards,

  • Panos
    • SLS

    Hi Amit ,

    I had a look in the chat and I see that you need to create a new post of a CPT when a survey is created.

    We'll need access to check how the surveys are created in order to find some available hook if possible. Could you please send in admin and ftp access using our contact form : :
    Send in:Subject: "Attn: Panos Lyrakis"
    and include following information:
    - Admin login:
    Admin username
    Admin password
    Login url

    - FTP credentials
    (and port if required)

    - link back to this thread for reference


  • Panos
    • SLS

    Hi Amit ,

    Could you please ad the following snippet in a mu-plugin:

    function wpmudev_add_post_on_poll( $post_ID, $post, $update ){
    	if( 'revision' == $post->post_type ){
    		$post = get_post( $post->post_parent );
    	remove_action( 'wp_insert_post', 'wpmudev_add_post_on_poll', 10 );
    	if( 'poll' != $post->post_type || 'auto-draft' == $post->post_status ){
    	if( get_post_meta( $post_ID, '__poll_page_created', true ) ){
    	$page_id = wp_insert_post(array (
    	   'post_type' => 'page',
    	   'post_title' => '[Page] - ' . $post->post_title,
    	   'post_content' => '[totalpoll id="' . $post->ID . '"]',
    	   'post_status' => 'publish'
    	if( ! is_wp_error( $page_id ) ){
    		update_post_meta( $post_ID, '__poll_page_created', true );
    add_action( 'wp_insert_post', 'wpmudev_add_post_on_poll', 10, 3 );

    and test if it creates a new page?


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.