- This topic has 13 replies, 2 voices, and was last updated 3 years, 4 months ago by Leo.
-
AuthorPosts
-
August 29, 2018 at 5:20 pm #663775Feri
Hi,
Based on this tutorial LINK
function my_nav_menu_author_link( $menu ) { if( !is_user_logged_in() ){ return $menu; } else { $link = get_author_posts_url( get_current_user_id() ); $class = is_author() ? ' class="current-menu-item"' : ''; $author_archive_link = '<li' . $class . '>' . '<a href="' . $link . '" >' . __( 'My posts' ) . '</a>' . '</li>'; $menu = $menu . $author_archive_link; return $menu; } } add_filter( 'wp_nav_menu_items', 'my_nav_menu_author_link' );
i already success to make author archive link at navigation menu. screenshot: image default location is always at the right corner navigation menu. its not flexible.
i want to make that author menus link to become Sub menu for another link menu. Something Like: ACCOUNT – AUTHOR MENU etc
the problem is that author menus only show at front end without another setting at Menus Structure (Appearance – Menus)
Need your help..
Thank You
August 29, 2018 at 7:34 pm #663826TomLead DeveloperLead DeveloperHi there,
Have you considered using a plugin like this?: https://wordpress.org/plugins/nav-menu-roles/
Let me know π
August 29, 2018 at 7:43 pm #663831FeriHi,
Sorry for my bad explanation, but this is not about navigation menu role.
I just want to add author post link to the nav menu. Something like “Login Logout Link” Nav Menus but for “Author Post Link”.
The Author link is work actually but i can not setting the position to another menus place (sub menus, etc)
August 29, 2018 at 7:47 pm #663833TomLead DeveloperLead DeveloperAh, my mistake!
I’m not sure if you can dynamically insert a link as a sub-menu unfortunately.
What you could do is use the plugin I suggested to show the menu item only for logged in users. That way you can add a custom link as a sub-menu item.
Then you can use a plugin like this to insert a shortcode as the custom link URL: https://wordpress.org/plugins/shortcode-in-menus/
Then create a shortcode for the URL:
add_shortcode( 'author_url', function() { return get_author_posts_url( get_current_user_id() ); } );
August 29, 2018 at 8:50 pm #663853Feriyes perfect! it work…
but, previously i have another plugin for Nav Menu Role, the plugin is “If Menu β Visibility control for Menu Items”. Both of great plugin, btw…
one question again, how to prevent 404 of Author pages without posts? when i click Author Link Menus (without post) suddenly directed to 404 pages.
is possible to customise the author page without post become someting like “No Post bla bla”?
August 30, 2018 at 10:46 am #664598TomLead DeveloperLead DeveloperHi there,
Is it a 404 page, or a no results page? Can you link me to an example?
August 30, 2018 at 5:38 pm #664828Ferisorry my mistake, its not 404 but no result/nothing found page. so i think the problem is solved.
but at the end of the page author (without post) there is “Load More” button. how to remove it?
screenshot: Load More Button
thank you so much for your help and support.
August 30, 2018 at 10:08 pm #664920TomLead DeveloperLead DeveloperThat definitely shouldn’t be there. Just to confirm that you’re using GPP 1.7.2?
August 30, 2018 at 10:46 pm #664925FeriHi,
Yes, GP Premium 1.7.2.
Just sent you an email about the link to the profile author page.
thank you…
August 31, 2018 at 10:13 am #665422TomLead DeveloperLead DeveloperLooks like a bug.
For now, use this CSS:
.no-results + .load-more { display: none; }
August 31, 2018 at 5:12 pm #665630Ferithank you so much, Tom.
August 31, 2018 at 5:53 pm #665645TomLead DeveloperLead DeveloperNo problem! π
November 27, 2020 at 11:27 pm #1554124ZachThis suggestion isn’t working: https://wordpress.stackexchange.com/questions/378971/adding-author-url-to-nav-menu-via-shortcode
Basically, when you use that plugin with your shortcode the output is either plain text or if you put the shortcode in the custom link field it creates a url that looks like this: http://https://mysite.local
How do you stop it from outputting the extra http?
November 28, 2020 at 9:09 am #1555160LeoStaffCustomer SupportThat looks like a plugin’s issue and not a theme issue.
However it seems to work for the topic author though.
Can you open a new topic for your question first?
-
AuthorPosts
- You must be logged in to reply to this topic.