Custom fields into CPT template

Home Forums Jevelin Theme Custom fields into CPT template

Home Forums Jevelin Theme Custom fields into CPT template

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • kykm
    Participant

    Hi,

    I’ve created my own template single-mycenter.php for my custom post Centers. Also custom taxonomy (one category, “Location”) for those post. When someone fill a form, some info will post into a mycenter draft post.

    In my function.php

    // Centros from Contact Form 7
    
    function save_posted_data( $posted_data ) {
    $args = array(
    'post_type' => 'micentro',
    'post_status'=>'draft',
    'post_title'=>$posted_data['your-title'],
    'post_content'=>$posted_data['your-description'],
    'post_content'=>$posted_data['your-requisitos'],
    );
    $post_id = wp_insert_post($args);
    
    if(!is_wp_error($post_id)){
    if( isset($posted_data['your-title']) ){
    update_post_meta($post_id, 'your-title', $posted_data['your-title']);
    }
    if( isset($posted_data['your-description']) ){
    update_post_meta($post_id, 'your-description', $posted_data['your-description']);
    }
    if( isset($posted_data['your-requisitos']) ){
    update_post_meta($post_id, 'your-requisitos', $posted_data['your-requisitos']);
    }
    return $posted_data;
    }
    }
    
    add_filter( 'wpcf7_posted_data', 'save_posted_data' );

    I’m triying to pass all the meta-data to my single-mycenter.php template but it doesn’t work. The full template is a copy from single.php but i’m adding this:

    
    <div id="content" class="<?php if( isset($layout_sidebar) && $layout_sidebar ) : ?><p>content-with-<?php echo esc_attr( $layout_sidebar ); endif; ?>">
    <div class="blog-single blog-style-large"><!--?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $type = get_post_type( get_the_ID() ); if($type == 'micentro'){ your-title(); your-requisitos(); your-description(); } } endwhile; get_template_part( 'content', 'format-'.get_post_format() ); ?-->

    </div>
    </div>

    I’ve tried different ways to do it, but nothing is shown or I completly break the template (404). Where should I place my code to “call” some content in single-mycenter.php?

    Thank you

    Hi @kykm,

     

    Thanks for posting here.

     

     

    Developing custom code or providing assistance to develop it for custom functionality is beyond the scope of support that we provide here. Please see https://themeforest.net/item/jevelin-multipurpose-premium-responsive-wordpress-theme/14728833/support

     

    If you are not a developer then you can consider hiring a developer to develop it for you. You can hire a developer from any freelance site. Shufflehound recommends the developer https://www.upwork.com/freelancers/~011652ffec8865c6d5

     

    Best regards,
    Shufflehound team

Viewing 2 posts - 1 through 2 (of 2 total)