artemsemkin

Rhye navigation for portfolio Items of the same category

Jan 12th, 2021
832
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $portfolio_nav_direction = get_theme_mod( 'portfolio_nav_direction', 'forward' );
  4. $next_post               = $portfolio_nav_direction === 'forward' ? get_previous_post(true, '', 'arts_portfolio_category') : get_next_post(true, '', 'arts_portfolio_category');
  5. $current_id              = get_the_ID();
  6. $next_link;
  7. $next_title;
  8. $next_image_id;
  9. $attrs_link = '';
  10.  
  11. $portfolio_nav_background               = arts_get_overridden_document_option( 'portfolio_nav_background', 'page_portfolio_nav_settings_overridden', 'bg-light-1' );
  12. $portfolio_nav_theme                    = arts_get_overridden_document_option( 'portfolio_nav_theme', 'page_portfolio_nav_settings_overridden', 'dark' );
  13. $portfolio_nav_divider_enabled          = arts_get_overridden_document_option( 'portfolio_nav_divider_enabled', 'page_portfolio_nav_settings_overridden', true );
  14. $portfolio_nav_image_transition_enabled = get_theme_mod( 'portfolio_nav_image_transition_enabled', true );
  15. $portfolio_nav_scroll_down_enabled      = get_theme_mod( 'portfolio_nav_scroll_down_enabled', true );
  16. $portfolio_nav_scroll_down_label        = get_theme_mod( 'portfolio_nav_scroll_down_label', esc_html__( 'Keep Scrolling', 'rhye' ) );
  17. $portfolio_nav_headings_preset          = get_theme_mod( 'portfolio_nav_headings_preset', 'h1' );
  18. $portfolio_nav_labels_preset            = get_theme_mod( 'portfolio_nav_labels_preset', 'subheading' );
  19. $portfolio_nav_next_label               = get_theme_mod( 'portfolio_nav_next_label', esc_html__( 'Next Project', 'rhye' ) );
  20.  
  21. $categories = array();
  22. $current_categories = arts_get_taxonomy_term_names( $current_id, 'arts_portfolio_category' );
  23. foreach ( $current_categories as $item ) {
  24.   array_push( $categories, $item['slug']);
  25. }
  26.  
  27. $posts = get_posts(
  28.   array(
  29.     'post_type'      => 'arts_portfolio_item',
  30.     'posts_per_page' => -1,
  31.     'tax_query' => array(
  32.       array(
  33.         'taxonomy' => 'arts_portfolio_category',
  34.         'field' => 'slug',
  35.         'terms' => $categories, // include only posts of the current categories (slugs)
  36.       )
  37.    )
  38.   )
  39. );
  40.  
RAW Paste Data