• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Filterable custom post type isotope

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Filterable custom post type isotope

This topic is: not resolved

Tagged: CPT, filterable grid, isotope, taxonomy archive

  • This topic has 1 reply, 2 voices, and was last updated 8 years ago by Brad Dalton.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • July 11, 2017 at 10:31 am #208974
    Maffy
    Participant

    Hi, I need to create a custom post type (Resource) with a tassonomy Category Resource.
    The archive page should view all custom posts with categories that can be filtered with isotopes. Similar of this http://tutorials.llamapress.com/portfolio/
    I found this code explained in various tutorials but custom posts do not appear on the archive page. I do not understand what the problem is. Can you help me? Thank you!

    code on file function.php

    
    
    /** Creates resources featured image for archive grid */
    add_image_size( 'resources', 330, 230, TRUE );
    
    /** Create resourse custom post type */
    add_action( 'init', 'resources_post_type' );
    function resources_post_type() {
        register_post_type( 'resources',
            array(
                'labels' => array(
                    'name' => __( 'Resources' ),
                    'singular_name' => __( 'Resources' ),
                ),
                'exclude_from_search' => true,
                'has_archive' => true,
                'hierarchical' => true,
                'taxonomies'   => array( 'resources-type' ),
                'public' => true,
                'rewrite' => array( 'slug' => 'resources' ),
                'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' ),
            )
        );
    }
    /* Register Resources Taxonomy */
    add_action( 'init', 'create_resources_tax' );
    function create_resources_tax() {
        register_taxonomy(
            'resources-type',
            'resources',
            array(
                'label' => __( 'Resources Type' ),
                'hierarchical' => true
            )
        );
    }
    

    code on archive-resources.php

    <?php
    /**
     * The custom resources post type archive template for a Filterable resources
     */
    
    # Force full width content
    add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
    
    wp_enqueue_script('isotope', get_stylesheet_directory_uri() . '/js/jquery.isotope.min.js', array('jquery'), '1.5.25', true);
    wp_enqueue_script('isotope_init', get_stylesheet_directory_uri() . '/js/isotope_init.js', array('isotope'), '', true);
    
    //* Add custom body class
    add_filter( 'body_class', 'filerable_resources_add_body_class' );
    
    //* Filterable resources custom body class
    function filerable_resources_add_body_class( $classes ) {
        $classes[] = 'filterable-resources-page';
            return $classes;
    }
    
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'filterable_resources_do_loop' );
    
    /**
     * Outputs a custom loop
     *
     * @global mixed $paged current page number if paginated
     * @return void
     */
    function filterable_resources_do_loop() { ?>
    
        <header id="page-heading" class="entry-header">
            <?php $terms = get_terms( 'resources-type' ); ?>
            <?php if( $terms[0] ) { ?>
                <ul id="resources-cats" class="filter clearfix">
                    <li><a href="#" class="active" data-filter="*"><span><?php _e('All', 'genesis'); ?></span></a></li>
                    <?php foreach ($terms as $term ) : ?>
                        <li><a href="#" data-filter=".<?php echo $term->slug; ?>"><span><?php echo $term->name; ?></span></a></li>
                    <?php endforeach; ?>
                </ul><!-- /resources-cats -->
            <?php } ?>
        </header><!-- /page-heading -->
    
        <div class="entry-content" itemprop="text">
             <?php if( have_posts() ) { ?>
                <div id="resources-wrap" class="clearfix filterable-resources">
                    <div class="resources-content">
                        <?php $wpex_count=0; ?>
                        <?php while( have_posts() ) : the_post() ?>
                            <?php $wpex_count++; ?>
                            <?php $terms = get_the_terms( get_the_ID(), 'resources-type' ); ?>
                            <?php if ( has_post_thumbnail($post->ID) ) { ?>
                                <article class="resources-item col-<?php echo $wpex_count; ?> <?php if( $terms ) foreach ( $terms as $term ) { echo $term->slug .' '; }; ?>">
                                    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo genesis_get_image( array( size => 'resources' ) ); ?>
                                    <div class="resources-overlay"><h3><?php the_title(); ?></h3></div><!-- resources-overlay --></a>
                                </article>
                            <?php } ?>
                        <?php endwhile; ?>
                    </div><!-- /resources-content -->
                </div><!-- /resources-wrap -->
            <?php } ?>
            <?php wp_reset_postdata(); ?>
        </div><!-- /entry-content -->
    
    <?php }
    
    genesis();
    
    July 11, 2017 at 3:47 pm #209002
    Brad Dalton
    Participant

    Hello Maffy

    Happy to point you in the right direction.

    They will if you create a taxonomy-resources-type.php template which uses the WordPress Template Hierarchy.

    I suggest you add support for taxonomy types rather than use categories.

    Here's some code you can use as a guide to create the CPT and Taxonomy support. Swap out all instances of Portfolio with the name of your CPT


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble