• Resolved trint

    (@trint)


    Hi there,
    I’m doing a multiple portfolios project with categories, artists and I have an issue…
    I’ve made a custom post type with custom taxonomies and custom tag :
    Here are fields:
    – Title: Project title
    – Custom taxonomy 1: Projet categories (cat1, cat2)
    – Custom taxonomy 2: Artist (artist1, artist2, etc…)
    – Custom tag: Izotope portfolio filters (All, tag1, tag2, tag3, etc…)
    I can’t reach to display Izotope portfolio filters (tags) that correspond to posts and selected Artist.

    For example:
    My parent page (page-template.php) displays all artists which belong to cat1.
    Clic on an artist -> list artist’s projects with tag filters (taxonomy-portfolio_artist.php).
    If I choose another artist, it display same filters, not filters which belong to this artist posts (projects).

    Here is my taxonomy-portfolio_artist.php code :

    <?php get_header(); ?>
    <header class="page-header clr">
    <h1 class="page-header-title"><?php echo single_term_title(); ?></h1>
    
    <?php $posttype_obj = get_post_type_object( get_post_type( ) ); ?>
    <?php $portfolio_terms = get_terms( 'portfolio_tag', array( 'orderby' => 'name', 'order' => 'ASC' ) ); ?>
    
    <?php if ( $portfolio_terms ) { ?>
    <ul class="tax-archives-filter clearfix">
    <li class="project-filter"><a href="<?php echo get_post_type_archive_link( $post->post_type ); ?>" title="<?php echo $posttype_obj->label; ?>" class="active"><?php _e('ALL','wpex'); ?></a></li>
    <?php foreach( $portfolio_terms as $portfolio_term ) : ?>
    <li><a href="<?php echo get_term_link( $portfolio_term->slug, 'portfolio_tag'); ?>" title="<?php echo $portfolio_term->name; ?>"><?php echo $portfolio_term->name; ?></a></li>
    <?php endforeach; ?>
    </ul><!-- .tax-archives-filter -->
    <?php } ?>
    </header><!-- /page-heading -->
    
    <?php
    // The Loop
    ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php $categories = get_the_terms( $post->ID , 'portfolio_category' );?>
    <?php $artists = get_the_terms( $post->ID , 'portfolio_artiste' );
    foreach($artists as $artist);
    foreach($categories as $category);
    $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    ?>
    
    <a href="<?php echo esc_attr($url)?>" title="<?php echo get_post_meta($post->ID, 'meta_client', true); ?>"  rel="lightbox[portfolio-lightbox]">
    <article id="post-<?php the_ID(); ?>" <?php post_class('homepost'); ?>>
    <div class="homepage_post-img"><?php the_post_thumbnail('medium');?></div>
    <h2 class="projet-title"><?php the_title(); ?></h2>
    <!--<h2 class="artist-name"><?php echo esc_attr($artist->name)?></h2>-->
    <h3 class="client-name"><?php echo get_post_meta($post->ID, 'meta_client', true); ?></h3>
    <h3 class="project-category"><?php echo esc_attr($category->name)?></h3>
    <p><?php the_content(); ?></p>
    </article><!-- #post-<?php the_ID(); ?> -->
    </a> 
    
    <?php endwhile; // end of the loop. ?>
    
    <?php get_footer(); ?>

    Any help would be appreciated.

Viewing 15 replies - 1 through 15 (of 22 total)
  • Thread Starter trint

    (@trint)

    I think a $post->ID for portfolio terms is missing…

    Thread Starter trint

    (@trint)

    Nobody ?

    Hi trint,

    Would you please provide some url of webpage so that we can check the issue and help you with ? Also, can you tell us which theme you are using, is it from wordpress.org ? or some premium theme ?

    Thread Starter trint

    (@trint)

    Hello,
    Thanks for your answer.
    For the moment I develop with Uwamp on my computer.
    I will send it on my server so as to give you an url.
    I use a child theme I made from the theme Adamos: https://wordpress.org/themes/adamos/
    I’ll keep you in touch when it’s done.
    All the best.

    Thread Starter trint

    (@trint)

    Hello again,
    here is the test version for the website: test
    here is the back office custom post type fields: screenshot
    Tomorrow I’ll insert isotope classes.
    Thanks for your support.

    Thread Starter trint

    (@trint)

    Hello, I change my mind and my approach :
    here is the new code with masonry working like a charm!
    However, filters are still not working…
    I need to update the test version, still the older one on the server.

    <?php get_header(); ?>
    
    <div id="primary_home" class="content-area">
    
    <div id="content" class="fullwidth" role="main">
    
    <header class="entry-header">
    <h1 class="entry-title"><?php echo single_term_title(); ?></h1>
    </header><!-- /page-heading -->
    
    <ul id="filters">
    
    <li><a href="#">Tous les projets</a></li>
    <?php
    $terms = get_terms( 'portfolio_tag', array( 'orderby' => 'name', 'order' => 'ASC' ) );
    $count = count($terms);
    if ( $count > 0 ){  //If there are more than 0 terms
    foreach ( $terms as $term ) {  //for each term:
    echo "
    <li><a href='#'>slug."'>" . $term->name . "</a></li>\n";
    }
    }
    ?>
    
    <?php
    // The Query
    $the_query = new WP_Query(
    array(
    'post_type' => 'portfolio',
    'showposts' => '-1',
    'posts_per_page' => '50',
    'category' => '',
    'no_found_rows' => true,
    'ignore_sticky_posts' => true,
    'orderby' => 'date',
    'order' => 'DESC',
    )
    );
    ?>
    <div id="isotope-list">
    <?php
    foreach( $posts as $post ) : setup_postdata( $post );?>
    <?php $categories = get_the_terms( $post->ID , 'portfolio_category' );?>
    <?php $artists = get_the_terms( $post->ID , 'portfolio_artiste' );
    foreach($artists as $artist);
    foreach($categories as $category);
    $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    ?>
    
    <div class="item">
    <a>" title="<?php echo get_post_meta($post->ID, 'meta_client', true); ?> - <?php echo get_post_meta($post->ID, 'meta_nom', true); ?> - <?php echo get_post_meta($post->ID, 'meta_desc', true); ?>"  rel="lightbox[lightbox]">
    <article id="post-<?php the_ID(); ?>" <?php post_class('post-item '. $post_clr_margin); ?>>
    <div class="homepage_post-img"><?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image'); endif;?></div>
    <div class="homepage_post-img"><?php the_post_thumbnail('medium');?></div>
    <div class="post-content">
    <h2 class="projet-title"><?php the_title(); ?></h2>
    <!--<h2 class="artist-name"><?php echo esc_attr($artist->name)?></h2>-->
    <h3 class="client-name"><?php echo get_post_meta($post->ID, 'meta_client', true); ?></h3>
    <h3 class="project-category"><?php echo esc_attr($category->name)?></h3>
    <p class="home-content"><?php the_content(); ?></p>
    </div>
    </article><!-- #post-<?php the_ID(); ?> -->
    </a>
    </div><!-- .item -->
    
    <?php endforeach; ?> 
    
    </div><!-- .isotope-list -->
    
    </div><!-- #content .site-content -->
    
    </div><!-- #primary .content-area -->
    
    <?php get_footer(); ?>

    Please help me on this.
    Best.

    Thread Starter trint

    (@trint)

    I updated test website with masonry layout working.
    here is the test new version: test

    Thread Starter trint

    (@trint)

    It makes sense that it doesn’t works but I don’t know how to find the solution.

    Thread Starter trint

    (@trint)

    Posts query needs to be before $terms = get_terms ?

    Thread Starter trint

    (@trint)

    Nobody ?
    Getting WordPress Term Results that are Relative to a Different Taxonomy
    Do you think this could be a solution so as to get the filter list which corresponds to artist ?

    @trint :- Sorry for late reply, i have checked your website and on this page , isotope filtering doesn’t seems to work, so for example when we are on this tag “Tous les projets” we get all of them, the first one which says “Project 06” is attached to tag06 as well(have checked by inspect element firebug), but when we click on “tag06” in title we dont get results for “tag06” projects, is this the problem ? Isotope filtering doesn’t seems to be working ?

    Thread Starter trint

    (@trint)

    Hello,
    don’t worry for late reply, it’s already nice to answer 😉
    Yes the problem is that filtering doesn’t works.

    The problem is the project boxes are not having class names as the title, for isotope to work, it will check for class name “tago6” or any tag in the article (portfolio) boxes, but the class name seems to be not correct. So, below is the code

    function adamoschild_assign_custom_post_class( $classes ) {
    	global $post;
    	if(get_post_type( $post->ID ) == "portfolio"){
    	$term_list = wp_get_post_terms($post->ID, 'portfolio_tag', array("fields" => "all"));
    	foreach($term_list as $term_single) {
    		$classes[] = $term_single->name;
    	}
    	}
    	return $classes;
    }
    add_filter( 'post_class', 'adamoschild_assign_custom_post_class' );

    Put this code inside functions.php of child theme, and check if it solves your problem, basically what this code does is put correct class names to article boxes based on tags they are assigned, this code is not tested, so just try it once if it solves your problem, please make sure in code i have assumed that you have post type “portfolio” and taxonomy called “portfolio_tag”.

    Thread Starter trint

    (@trint)

    Thanks for your code.
    I put your code inside function.php. Seems to not work.
    You’re right :
    register_post_type( ‘portfolio’, $args );
    register_taxonomy( ‘portfolio_tag’, array( ‘portfolio’ ), $taxonomy_portfolio_tag_args );

    Thread Starter trint

    (@trint)

    On artist02 page it would be only tag04 tag05 tag06 filters and not all tags.

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘List posts from custom post type with custom taxonomies categories and tags’ is closed to new replies.