Related items in portfolio item

Home Forums Jevelin Theme Related items in portfolio item

Home Forums Jevelin Theme Related items in portfolio item

This topic contains 3 replies, has 2 voices, and was last updated by  Shufflehound Support 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Hi I would like the related items to ACTUALLY be related and not just random items… How can I make all related items be from the same category of the portfolio item that is viewed?

     

    Thanks,

    David.

    Hi David,

     

    I hope you are well today and thank you for your question.

     

    To achieve this you have to overwrite following theme file in Jevelin child theme and change the code on line number 491

     

    /jevelin/framework-customizations/extensions/portfolio/views/single.php

     

    Best regards,
    Shufflehound team

    dehed
    Participant

    Hi

     

    I tried editing, I added this to get the post id’s from the current category:

     

    
    $taxcategory = get_the_category();
    $idcategory = $taxcategory[0]->cat_ID;
    $post_ids_related = get_posts(array(
    'numberposts' => -1, // get all posts.
    'tax_query' => array(
    array(
    'taxonomy' => 'category',
    'field' => 'id',
    'terms' => $idcategory,
    ),
    ),
    'fields' => 'ids', // Only get post IDs
    ));
    

    And then changed the following to:

    
    $portfolio_items = new WP_Query(array(
    'post_type' => 'fw-portfolio',
    'posts_per_page' => 4,
    'orderby' => 'rand',
    'post_status' => 'publish',
    'post__in' => $post_ids_related
    
    ));
    

    but it doesn’t seem to work… Help?

    Instead of get_the_category you have to use get_the_terms function and also use post_type argument in both the queries.

     

    Developing custom code for custom functionality is beyond the scope of support that we provide here. Please see https://themeforest.net/item/jevelin-multipurpose-premium-responsive-wordpress-theme/14728833/support

     

    If you are not a developer then you can consider hiring a developer to develop it for you. You can hire a developer from any freelance site. Shufflehound recommends the developer https://www.upwork.com/freelancers/~011652ffec8865c6d5

Viewing 4 posts - 1 through 4 (of 4 total)