Templates and meta

I want to pass some custom fields in a CPT to a post. I have some code, but I dunno how to “integrate” it.

I’m doing some stuff in a WP template (which is not mine, and this is the main problem).

Code

I have this single-job.php, which is -copy from single.php- post template for a CPT.

<?php
/**
* Job Post
*/
if( defined(‘FW’) ) :
$elements = jevelin_option( ‘post_elements’ );
if( jevelin_option( ‘post_layout’ ) == ‘sidebar-left’ || jevelin_option( ‘post_layout’ ) == ‘sidebar-right’ ) :
$layout_sidebar = esc_attr( jevelin_option( ‘post_layout’ ) );
endif;
else :
$layout_sidebar = ‘sidebar-right’;
endif;

get_header();
?>

<div id=”content” class=”<?php if( isset($layout_sidebar) && $layout_sidebar ) : ?>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();

get_template_part( ‘content’, ‘format-‘.get_post_format() ); ?>

<?php /* Clear unclosed floats */ ?>
<div class=”sh-clear”></div>

<?php /* Show page links navigation */ ?>
<?php jevelin_page_links(); ?>

<?php /* Show Tags */ ?>
<?php if( count( wp_get_post_tags( get_the_ID() ) ) > 0 ) : ?>
<div class=”sh-blog-tags”>
<h5><?php esc_html_e( ‘Tags In’, ‘jevelin’ ); ?></h5>
<div class=”sh-blog-tags-list”>
<?php foreach( get_the_tags( get_the_ID() ) as $tag ) :
$term_link = get_tag_link( $tag->term_id );
?>
<a href=”<?php echo esc_url( $term_link ); ?>” class=”sh-blog-tag-item”>
<?php echo esc_attr( $tag->name ); ?>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>

I also have this code that should pass my custom fields to the post text.

<?php
if ( have_posts() ) {
while ( have_posts() ) : the_post();
$type = get_post_type( get_the_ID() );
if($type == ‘job’){
your-title();
your-requisitos();
your-description();
}

endwhile;
}
?>

I’ve tried to “integrate” both codes in these lines but I don’t know how to do it (it crashes).

<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();

get_template_part( ‘content’, ‘format-‘.get_post_format() ); ?>

Read more here:: Templates and meta

Leave a Reply

Your email address will not be published. Required fields are marked *