- This topic has 7 replies, 2 voices, and was last updated 3 years, 5 months ago by
David.
-
AuthorPosts
-
May 2, 2022 at 2:09 am #2206166
Sebastian
Hi guys,
I have designed a 4-col footer and would appreciate your input for how to actually implement it in the theme.
In my footer I would like to add dynamic links such as login / logout link, my orders link, my deliveries link etc. These links should render different depending of, if the visitor is logged in or not.
At first I tried the widgets but found myself extremely locked in and limited not able to customize anything really.In the past I would just add everything into the footer.php file and be done with it.
Example for my simple login/logout links:
<li> <?php if(is_user_logged_in) { ?> <a href="<?php echo wp_logout_url(); ?>">Logout</a> <?php } else { ?> <a href="<?php echo wp_login_url(); ?>">Login</a> <?php } ?> </li>
But now with all the block functionality I don’t know if this is the right way to go? I mean, what about all these do_actions() ? Is it safe to input html between these or are there better, more future proof ways of doing this? I know there’s this thing you call elements. I just don’t see how or where it should go together…
I hope I’m making sense here.
Thanks.May 2, 2022 at 5:43 am #2206341David
StaffCustomer SupportHi there,
if you’re using Blocks then WP core does provide a Login / Logout Block for that purpose.
Are the other links dynamic ? If so then they may need converting to shortcodes. Let me knowMay 16, 2022 at 2:10 am #2220841Sebastian
Hi David,
Yes, just about every link in the column will be dynamic. I would like to have the following links for logged in users:
- Login / logout
- My Account
- My orders (Account Page->Orders)
- My Shippings/deliveries (not sure yet if or how this would be implemented)
- My Adresses
May 16, 2022 at 7:06 am #2221069David
StaffCustomer SupportSimplest option would be to use a plugin like this:
https://en-gb.wordpress.org/plugins/custom-sidebars/
Then you could create a different footer widget area for logged in and logged out users.
Alternative is to create a Shortcode to display the content in the footer.
May 18, 2022 at 12:43 am #2223301Sebastian
Well, I would really prefer not to use any more plugins.
Actually I was thinking about using the wp_list_pages function and explicitly pass the id(s) for the pages I need. The question is if this is possible using a hook element from you or do I need to revert to inserting this directly into the footer.php?
I know it’s not possible to hook directly into the content since there are nothing to hook on to, so what do I do? This means I’m back to square one… Please, how can I solve this?
May 18, 2022 at 3:28 am #2223435David
StaffCustomer SupportThe alternative is to use a Block Element to build your Footers.
https://docs.generatepress.com/article/block-element-site-footer/
You can then create one for Logged in user and one for Logged out user.
This will work if you can add static links for each of the menu itemsNote if you use GenerateBlocks to build the footers, you will need to set its Dynamic CSS to Inline in Dashboard > GenerateBlocks > Settings.
May 19, 2022 at 4:13 am #2225237Sebastian
It turns out I went oldschool instead with a custom footer.php file. I’m not smart enough for getting things to work the way I intended it to by using blocks :).
Thanks anyway.
May 19, 2022 at 4:34 am #2225252David
StaffCustomer Support🙂 Glad to hear you have a solution!
-
AuthorPosts
- You must be logged in to reply to this topic.