Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1491033

    Hi there,

    When using the next and previous buttons in a standard post, I’d like the next or previous post to be from the same category.
    I found this filter (in a topic from 2017 …) but that doesn’t work for me:

    add_filter(‘avia_post_nav_categories’, ‘use_same_category_filter’);
    function use_same_category_filter($same_category)
    {
    $same_category = true;
    return $same_category;
    }

    Is there another solution maybe?

    Beste regards,

    Steven

    #1491062

    try first this shorter form – maybe that will work for you.
    (do not know if the old filter is still ther avia_ …)
    there are more complex snippets – but in almost all installations this will work:

    function enfold_customization_postnav($settings){
      $settings['skip_output'] = false;
      $settings['same_category'] = true;
      return $settings;
    }
    add_filter('avf_post_nav_settings','enfold_customization_postnav', 10, 1);

    edit: here is one with more options:

    function my_avf_post_nav_settings( array $settings ){
      if( true === $settings['is_hierarchical'] ){
        $settings['skip_output'] = true;
        return $settings;
      } 
      if( ! in_array( $settings['type'], array( 'post', 'portfolio' ) ) ){
        $settings['skip_output'] = false;
        return $settings;
      }
      $settings['same_category'] = true;
      $settings['is_fullwidth'] = false;
      $settings['skip_output'] = false; 
      return $settings;
    }
    add_filter( 'avf_post_nav_settings', 'my_avf_post_nav_settings', 10, 1 );
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.