• Hi,

    I’m working on a wordpress site with a lot of pages. But I’m strunggling with how to order my post and how to link to them.

    What I need:

    Let’s say I have 2 pages (page 1 and page 2) and 2 categories. On page 1 I want to have a menu in the sidebar that shows all post that are in category 1.

    On page 2 I want to have only a menu of posts that are post in category 2.

    What is the best way and plugin(s) to do this.
    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,
    I haven’t heard about such a plugin and I’m having a hard time imagining that someone has created such a flexible plugin to let you arrange the menus on category pages by category and work with most themes…
    So what I would do if I were you I would start by creating a child theme and edit the category template (category.php) in wich you can create different menus/html pages filttered by the category.
    It will take some wordpress/php knowledge but is doable.
    Regards

    Display Widgets is a great plugin that allows you to control which widgets appear on which pages (and more).

    You could use that in conjunction with Recent Posts Widget Extended, which allows you to show a list of recent post links of a specific category.

    So you would create two widgets for your two categories, then set one to only display on one page and the other to only display on the other page.

    Thread Starter LeffDesign

    (@leffdesign)

    Thanks for your response, good idea. Right now I’m working with the advanced menu widget and Auto Submenu.

    This works but I have to make a lot of pages, so I think your way is better. I’ll give it a try.

    Thread Starter LeffDesign

    (@leffdesign)

    Hm it’s not working the right way yet. Shaun Scovil, your solution works for posts indeed.

    But what if I want to do the same as with pages? I thought it was working with the Menu Widget, Auto Submenu and the Display plugin. But not yet perfect.

    Let me explain:

    – I post a new child page
    – It gets auto added to a menu (with Auto Submenu)
    – The menu widget shows me the menu with the new child page
    – The display widget plugin does not add the page to display the menu on that page, so I have to do this manually
    – There should be an option in Display widgets where you can select a page and then a setting like: ‘Also show on all child pages’

    Anyone a good solution for this? Thanks!

    Another option might be to add support for categories on your pages, by adding this to your functions.php:

    function add_categories_to_pages_06202013(){
        register_taxonomy_for_object_type( 'category', 'page' );
    }
    add_action( 'init', 'add_categories_to_pages_06202013' );

    Then you could add something like this to your sidebar.php:

    <?php
        if ( is_page() ) :
            $cats = wp_get_object_terms( $post->ID, 'category', 'ids' );
            $args = array(
                'category__in'   => $cats,
                'posts_per_page' => 5,
                'post_type'      => 'post'
            );
            $query = new WP_Query( $args );
    ?>
    
        <?php if ( $query->have_posts() ) { ?>
            <ul class="sidebar-nav">
            <?php while( $query->have_posts() ) : $query->the_post(); ?>
                <li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>
            <?php endwhile; wp_reset_postdata(); ?>
            </ul>
        <?php } ?>
    
    <?php endif; ?>

    This is untested and might require a little tweaking, but should automatically show a list of five (5) post links that are in the same category as the current page.

    EDIT: Fixed sidebar code so that <ul> tags appear outside of the loop!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘The best way to order posts and menu?’ is closed to new replies.