Reply To: Masonry Layout with custom taxonomy templates.

Home Forums Pro Version Masonry Layout with custom taxonomy templates. Reply To: Masonry Layout with custom taxonomy templates.

#14959
Sandra Saenz
Participant

Hi,

thank You for a prompt reply.

Please take a look on my taxonomy-portfolio.php file:


<?php
/**
 * The taxonomy template file.
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package SandraSaenz
 */

get_header(); ?>

	<div class="col-md-12">
        <?php

        $taxonomy = get_queried_object()->slug;

        $args = array(
            'post_type' => 'my_portfolio',
            'posts_per_page'=> 20,
            'tax_query' => array(
                array(
                    'taxonomy' => 'portfolio',
                    'field'    => 'slug',
                    'terms'    =>  $taxonomy,
                ),
            ),
        );

        $query = new WP_Query( $args );

        if ( $query->have_posts() ) :

            /* Start the Loop */
            while ( $query->have_posts() ) : $query->the_post();

                /*
                 * Include the Post-Format-specific template for the content.
                 * If you want to override this in a child theme, then include a file
                 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                 */
                get_template_part( 'template-parts/content', 'portfolio' );

            endwhile;

            the_posts_navigation();

        else :

            get_template_part( 'template-parts/content', 'none' );

        endif; ?>

        <?php wp_reset_postdata(); ?>
	</div><!-- .col-md-12 -->

<?php
get_footer();

In this line I’ve injected my own template get_template_part( 'template-parts/content', 'portfolio' );. It looks like:


<?php

  $image = get_field ( 'portfolio_photo' );

?>

<div class="grid-item">
    <a href="<?php echo $image; ?>" data-rel="lightbox">
      <img src="<?php echo $image; ?>" class="img-responsive" alt="">
    </a>
</div>

Also, I’ve changed the plugin’s configuration and removed generic shortcode from the code. You are right. I can choose “Portfolio” post type and also I can select all my categories (taxonomies). Now it looks like:

The problem is that the plugin doesn’t work for me. Now on my category page I can see this:

As You can see all the images are laid out in one column and it looks like the plugin doesn’t work on this page (it doesn’t add any classes to my images).

Thank You for help.

Best regards,
Vladyslav Turak