New Landing How can we help? Themeforest Theme Support Flexform Modify the portfolio-carousel.php to display custom post types

Viewing 13 posts - 106 through 118 (of 118 total)
  • Posted in: Flexform
  • #17550
    sam_y2000
    Member
    Post count: 86
    This reply has been marked as private.
    #17551
    sam_y2000
    Member
    Post count: 86
    This reply has been marked as private.
    #17552
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi Sam,

    Sorry, didn’t check the code fully. Try this amended version, hopefully my edits work!

    // Create a query for the custom taxonomy
    function related_posts_by_taxonomy( $post_id, $taxonomy, $args=array() ) {
        $query = new WP_Query();
        $terms = wp_get_object_terms( $post_id, $taxonomy );
    
        // Make sure we have terms from the current post
        if ( count( $terms ) ) {
            $post_ids = get_objects_in_term( $terms[0]->term_id, $taxonomy );
            $post = get_post( $post_id );
            $post_type = get_post_type( $post );
    
            $args = wp_parse_args( $args, array(
                    'post_type' => $post_type,
                    'post__not_in' => array($post_id ),
                    'taxonomy' => $taxonomy
                ) );
            $query = new WP_Query( $args );
        }
    
        // Return our results in query form
        return $query;
    }
    

    – Ed

    #17555
    sam_y2000
    Member
    Post count: 86
    This reply has been marked as private.
    #17559
    sam_y2000
    Member
    Post count: 86
    This reply has been marked as private.
    #17562
    sam_y2000
    Member
    Post count: 86
    This reply has been marked as private.
    #17563
    sam_y2000
    Member
    Post count: 86
    This reply has been marked as private.
    #17647
    sam_y2000
    Member
    Post count: 86

    Good afternoon Ed,

    Thought id give it one last go myself – after some digging it turns out Pippin (easy content types) has a plugin called ‘related posts by taxonomy’ which supposedly provides the correct code for this and allows me to replace $related_posts_query->the_post(); with a simple echo pippin_related_posts();

    This works but strangely the output is also a continuous stream in the same way the solution you provided yesterday!

    I have disabled all plugins except: Easy Content Types, Custom Post Type Permalinks and Related Posts by Taxonomy.

    I am not sure how to proceed – I could add echo pippin_related_posts(); to the 2013 theme to see if it works but that doesn’t really help me! …I have now contacted Pippin for some advice.

    Thanks for all your help here Ed, if you do have any thoughts as to what may be causing this please do let me know.

    Regards

    Sam

    #17854
    sam_y2000
    Member
    Post count: 86

    Ed,

    Think I was perhaps barking up the wrong tree and went off on a tangent!

    I have gone back to the code you provided and it seems the continuous stream of thumbs likely indicates that the code is missing something…

    $related_posts_query = related_posts_by_taxonomy( $post->ID, ‘article-category’ );

    A. = a continuous stream of thumbnails of the current post – no related items present.

    $related_posts_query = related_posts_by_taxonomy( $post->ID, ” );

    B. = one thumb displayed – but this is the current post, not the related one.

    So I finally admit defeat! lol – thanks for all your help on this Ed, can’t believe this little issue is such a tricky bugger!

    So on that note let’s close this thread shall we as everything else is good and my migration begins Monday…

    Have a great weekend!

    Regards

    Sam

    #17899
    sam_y2000
    Member
    Post count: 86

    ok, it comes down to this bit of the code for functions.php:

    $args = wp_parse_args( $args, array(
    ‘post_type’ => $post_type,
    ‘post__not_in’ => array($post_id ),
    ‘taxonomy’ => $taxonomy
    ) );

    With it – the thumbnails of the current post are shown over and over again.

    Without it – only one thumb of the current post shows – no related items.

    This is the same behavior if I remove the ‘article-category’ part from the

    $related_posts_query = related_posts_by_taxonomy( $post->ID, ‘article-category’ );

    which replaces the original on line 247 of single.php

    $related_posts_query->the_post();

    So, I’m clearly no expert but I would say that the query is dodgy… perhaps Pippin will shine a light upon the situation.

    Never mind, could be time for that developer I guess …and several beers for me!

    Ciao ;0)

    #17958
    sam_y2000
    Member
    Post count: 86
    This reply has been marked as private.
    #18123
    Swift Ideas – Ed
    Keymaster
    Post count: 15264
    This reply has been marked as private.
    #18550
    Melanie – SUPPORT
    Member
    Post count: 11032

    Fantastic!

Viewing 13 posts - 106 through 118 (of 118 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register