<?php
/**
 * Template part for displaying portfolio content
 *
 */
get_header();
?>
<main id="primary" class="site-main">
<div class="container">
<?php 
    while ( have_posts() ) :
        the_post();
        $terms 		= wp_get_post_terms(get_the_ID(), 'portfolio_categories');
    ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <div class="top-wrapp">
        <header class="entry-header">
            <div class="pfolio-cat">
                <?php if ( $terms && !is_wp_error( $terms ) ) : 
                    $term = $terms[0];
                    while ($term->parent != 0) {
                        $term = get_term($term->parent, 'portfolio_categories');
                    }
                    echo esc_html($term->name);
                endif; ?>
		    </div>
            <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
        </header><!-- .entry-header -->

        <?php portfolio_one_post_thumbnail(); ?>
    </div>
    <div class="pfolio-body-wrapp">
        <div class="portfolio-content-wrapp">
            <div class="entry-content">
                <?php
                the_content();

                wp_link_pages(
                    array(
                        'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'portfolio-one' ),
                        'after'  => '</div>',
                    )
                );
                ?>
            </div><!-- .entry-content -->

            <?php if ( get_edit_post_link() ) : ?>
                <footer class="entry-footer">
                    <?php
                    edit_post_link(
                        sprintf(
                            wp_kses(
                                /* translators: %s: Name of current post. Only visible to screen readers */
                                __( 'Edit <span class="screen-reader-text">%s</span>', 'portfolio-one' ),
                                array(
                                    'span' => array(
                                        'class' => array(),
                                    ),
                                )
                            ),
                            wp_kses_post( get_the_title() )
                        ),
                        '<span class="edit-link">',
                        '</span>'
                    );
                    ?>
                </footer><!-- .entry-footer -->
            <?php endif; ?>
        </div>
        <?php portfolio_one_portfolio_meta_info($post) ?>
    </div>

</article><!-- #post-<?php the_ID(); ?> -->     
    
<?php endwhile; // End of the loop. ?>

</div>
</main><!-- #main -->
<?php
get_footer();