Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #25567

    Hello, I just one more question.

    In every blog post there are arrows on the left side and on the right side, which leads to previous/next blog post. Example here: http://jharden13.com/highlights/top-10-2012-2013-regular-season/

    But it’s really inconvenient since it jumps from one category to another.

    Can I use it so that it only includes the posts from the same category?

    If that’s not possible, how would I get rid of the arrows completely?

    Thanks again guys.

    #127405

    Yes – add following code to the bottom of functions.php:

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

    Please note that this code will only work for standard posts. Custom post types like the portfolio are not supported because of a bug in the wp core.

    #127406

    Beautiful. Thank you so much Dude!

    #127407

    Glad Dude could help :)

    Let us know if you have any other questions or issues.

    Regards,

    Devin

    #127408

    Is ist possible to use both versions of navigation?

    If someone starts from a specific (static) “category-page”, it would be appropriate to browse only inside the category. Otherwise – starting from the (static) “all-posts-page”, it would be usefull to see posts from all Categories in regular order by date.

    It would be nice, to start the filter shown above not in general in the functions.php but in the specific posts-pages:

    * Category-page: add category-filter

    * All-posts-page: remove category-filter

    Is that possible?

    Regards,

    Günter

    #127409

    I didn’t test this but you can try following code instead

    add_filter('avia_post_nav_categories', 'use_same_category_filter');
    function use_same_category_filter($same_category)
    {
    if(is_archive()) $same_category = true;
    return $same_category;
    }

    #127410

    Hi Dude,

    I have tried your proposal, but it don’t work. I do not know, if I had executed every option, because of the absent of know how. The only one that works, was ‘is_single()’ instead of ‘is_archive()’. But again, it operates for every post.

    Regards,

    Günter

    #127411

    Hey!

    Too bad – probably it’s not possible then because is_archive() is (afaik) the only way to check if you’re on an archive/category page or not.

    Best regards,

    Peter

    #127412

    Hi,

    I have found a nice small Plugin: smarter-navigation.1.3.2. This Plugin remembers, if an user comes from an archive- or category-page to a single post. Normally you have to replace only ‘previous_post_link(‘ and ‘next_post_link(‘ with ‘previous_post_smart(‘ and ‘next_post_smart(‘ and it should work.

    But I did not found these expressions in the enfold theme. I inserted prev- next- links, that really display only, when you are coming from a category-Page. But in this case I have two pairs of links: the enfold arrows for the next post and the links inside the category. What can I do? The used code-lines:

    <!-- previous post in catetegory -->
    <?php
    $prev_post_id = get_adjacent_id_smart( true );
    if( $prev_post_id ) {
    $args = array(
    'posts_per_page' => 1,
    'include' => $prev_post_id
    );
    $prevPost = get_posts( $args );
    foreach ( $prevPost as $post ) {
    setup_postdata( $post );
    ?>
    <div class="post-previous">
    <a>">«Previous Post</a>
    <a>"><?php the_post_thumbnail('thumbnail'); ?></a>
    <h4><a>"><?php the_title(); ?></a></h4>
    </div>
    <?php
    wp_reset_postdata();
    } //end foreach
    } // end if
    ?>
    <!-- next post in category with first line: $prev_post_id = get_adjacent_id_smart( ); -->

    Is it possible to include the link above into the enfold-arrows or at least to fade out the arrows, when needed? One idea is, to place the extra-links above the enfold-arrows in a div with higher z-index.

    Regards,

    Günter

    #127413

    Hi,

    It may be possible theoretically but can’t tell from a cursory look. At the moment IMO such a customization would be outside the scope of the support team, however you should definately add this to Enfold Feature Request List – https://kriesi.at/support/topic/enfold-feature-requests – and since you actually have code as opposed to all other suggestions, I am certain that Kriesi will know exactly how it fits into his schedule of enhancements.

    I think it makes sense. Thanks for finding this.

    Nick

    #127414

    Hi Nick,

    now I have found an individual solution with the smarter-navigation-plugin: I added the code above into a renamed copy from loop-index.php, invoked only by single.php. Therby I used the same html-tags and -classes as the theme. Additionaly I add an extra class ‘anzeigen’ to the $output in the ‘function avia_post_nav($same_category = false)’ in functions-enfold.php. Into the code in the loop I add a style block, that determines the extra class ‘anzeigen’ as ‘display: none’

    So the whole thing works now in every case. If I do not come from a category-Page, the code for ‘previous post in catetegory’ does obviously not work, or create any effect. In the other case, the standard-arrows are replaced by the smarter-navigation-arrows.

    Regards,

    Günter

    #127415

    Günter,

    Wow! Thats an excellent solution. I wasn’t thinking of doing it like that at all and thanks for sharing how you did it. Excellent work around.

    Thanks,

    Nick

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Can I use the navigation arrows for each category, not all?’ is closed to new replies.