简体   繁体   中英

WordPress navigation menu

I currently have a nav menu that is built with the following,

<?php 
            if(!is_user_logged_in()) {
                wp_page_menu('show_home=1&exclude=214&exclude_tree=80');
            } else {
                wp_page_menu('show_home=1&exclude=214');
            }
        ?>

My problem is that I have some BuddyPress pages that I need add to parent that is created by WordPress, basically I have a parent that is called 'Member Content'

That Member Content has children like, 'Surveys', 'Documents' but I also want Forums, Groups, Members from my BuddyPress install to be children of the member content also.

Buddypress has several pages you are going to have to call. You'll need to include the pages manually, so it would look something like this:

<?php 
        if(!is_user_logged_in()) {
            wp_page_menu('show_home=1&exclude=214&exclude_tree=80');
        } else {
            wp_page_menu('show_home=1&exclude=214');

class="selected"> //" title="">

        <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
            <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
        </li>

        <?php if ( bp_is_active( 'groups' ) ) : ?>
            <li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
                <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>/" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a>
            </li>

            <?php if ( bp_is_active( 'forums' ) && bp_is_active( 'groups' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) get_site_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() ) : ?>
                <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
                    <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>/" title="<?php _e( 'Forums', 'buddypress' ) ?>"><?php _e( 'Forums', 'buddypress' ) ?></a>
                </li>
            <?php endif; ?>
        <?php endif; ?>

        <?php if ( bp_is_active( 'blogs' ) && bp_core_is_multisite() ) : ?>
            <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
                <a href="<?php echo site_url() ?>/<?php echo BP_BLOGS_SLUG ?>/" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a>
            </li>
        <?php endif; ?>


        }
    ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM