- This topic has 13 replies, 2 voices, and was last updated 1 year, 5 months ago by
Leo.
-
AuthorPosts
-
August 29, 2018 at 5:20 pm #663775
Feri
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
GP Premium 1.7.2August 29, 2018 at 7:34 pm #663826Tom
Lead DeveloperLead DeveloperHi there,
Have you considered using a plugin like this?: https://wordpress.org/plugins/nav-menu-roles/
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentAugust 29, 2018 at 7:43 pm #663831Feri
Hi,
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 #663833Tom
Lead 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() ); } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentAugust 29, 2018 at 8:50 pm #663853Feri
yes 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 #664598Tom
Lead DeveloperLead DeveloperHi there,
Is it a 404 page, or a no results page? Can you link me to an example?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentAugust 30, 2018 at 5:38 pm #664828Feri
sorry 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 #664920Tom
Lead DeveloperLead DeveloperThat definitely shouldn’t be there. Just to confirm that you’re using GPP 1.7.2?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentAugust 30, 2018 at 10:46 pm #664925Feri
Hi,
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 #665422Tom
Lead DeveloperLead DeveloperLooks like a bug.
For now, use this CSS:
.no-results + .load-more { display: none; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentAugust 31, 2018 at 5:12 pm #665630Feri
thank you so much, Tom.
August 31, 2018 at 5:53 pm #665645Tom
Lead DeveloperLead DeveloperNo problem! π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 27, 2020 at 11:27 pm #1554124Zach
This 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 #1555160Leo
StaffCustomer 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?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.