• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

My Posts Link in AgentPress Pro

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › My Posts Link in AgentPress Pro

This topic is: not resolved

Tagged: Agentpress Pro, genesis_header_right, header right, nav menu, user_is_logged_in

  • This topic has 6 replies, 2 voices, and was last updated 3 years, 11 months ago by Angelo.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • February 2, 2019 at 6:02 pm #489247
    Angelo
    Member

    I would Like to show to Logged In Users , a link in menu ( My Posts) , I found this code , But the problem is that the function only works in Primary o Secondary menu, and I don’t Know how to show ( MY POSTS ITEM MENU) In AgentPress Pro Theme, in Header Right Widget Area menu navigation

    add_filter('wp_nav_menu_items', function( $items, $args ) {
        $index = 'primary'; // menu index key, if you're not sure then var_dump( $args->theme_location )
        global $current_user;
        if ( $current_user->ID && $index === $args->theme_location ) {
            $items .= sprintf(
                '<li id="menu-item-my-posts" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-my-posts menu-item-my-posts"><a href="%s">%s</a></li>',
                get_author_posts_url( $current_user->ID ),
                'My Posts'
            );
        }
        return $items;
    }, 10, 2);

    Here is an Image Exemple
    https://drive.google.com/file/d/1NyL47ooB1wCcn2gy6NFdbYmtfIlZfAmW/view

    https://www.facebook.com/angeloaguilarq
    February 2, 2019 at 6:03 pm #489248
    Angelo
    Member

    Here is the image exemple
    https://drive.google.com/file/d/1NyL47ooB1wCcn2gy6NFdbYmtfIlZfAmW/view

    February 2, 2019 at 11:05 pm #489253
    Brad Dalton
    Participant

    There's at least 3 ways you can do this :

    In your case, it might be easiest to reposition one of your themes menus to the header right hook and use the code you have or create a third menu and hook it to genesis_header_right.


    Get Help – Book Consultation.

    February 3, 2019 at 12:43 pm #489265
    Angelo
    Member

    I dont Know how to do that Brad 🙁

    February 3, 2019 at 10:29 pm #489274
    Brad Dalton
    Participant

    Several existing StudioPress themes use menus hooked to header right and some also have third menus added so you can look at theme to see how its done.

    Another option is to widget_nav_menu_args filter.

    Or, you can use a plugin like https://wordpress.org/plugins/widget-logic/ with the user_is_logged_in conditional tag


    Get Help – Book Consultation.

    February 8, 2019 at 10:00 am #489423
    Angelo
    Member
    This reply has been marked as private.
    February 15, 2019 at 5:25 pm #489571
    Angelo
    Member

    I found a way like this

    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item');
    function my_custom_menu_item($items)
    {
        if(is_user_logged_in())
        {
            global $current_user;
            $items .= sprintf(
                '<li class="menu-item"><a href="%s">%s</a></li>',
                get_author_posts_url( $current_user->ID ),
                'My Posts'
            );
        }
        return $items;
    }
  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble