- This topic has 7 replies, 2 voices, and was last updated 3 years, 11 months ago by
David.
-
AuthorPosts
-
January 4, 2020 at 1:41 am #1121517
byo
Hi,
I’m trying to add a widget area after: generate_after_archive_description
If i add the code in theme root folder “archives.php” file; the widgets does not display very well (hidden behind the posts grid)If i put the code in archives.php file found in (inc/structure/)
The widget display very wellI can’t use it in (inc/structure/) if themes update i will lose it,
Any idea what causing this and how to fix it?
January 4, 2020 at 4:48 am #1121643David
StaffCustomer SupportHi there,
we are looking at implementing a new Hook that comes just before the Loop to make this sort of thing easier. In the meantime what happens if you use the:
generate_after_archive_title
hook?January 4, 2020 at 5:51 am #1121682byo
you mean use the hook in functions.php to display the widget?
I’m using “widget visibility” plugin for managing where every widget is displayed
i have a good number of widgets, if i had to use this method:
https://docs.generatepress.com/article/using-hooks/it will be very hard to manage
If there is a way to display the whole widget area, and let the plugin “widget visibility” manage the rest, that will be good.
January 4, 2020 at 6:47 am #1121728David
StaffCustomer SupportOnce you have registered your custom Widget Area you would then hook that into
generate_after_archive_title
via your functions.php or using the GP Hook Element.You can then manage what is displayed in that widget area using the Widget Visibility plugin.
January 4, 2020 at 7:02 am #1121861byo
There is documentation on how to that in themes like Genesis, i already used it, but Generatepress, there is not, or i could not find it:
//* Add widget area in gp archive pages add_action( 'generate_after_archive_title', 'add_widget_area_gp' ); function add_widget_area_gp() { if ( is_archive() ) gp_widget_area ('archive-widget', array( 'before' => '<div class="archive-widget"><div class="wdgt-aarchive">', 'after' => '</div></div>', ) ); }
This code does not work, i could not find what to replace this with “gp_widget_area” ?
January 4, 2020 at 7:22 am #1121873David
StaffCustomer SupportThis article in the Codex explains how to display your widget area:
https://codex.wordpress.org/Widgetizing_Themes#How_to_display_new_Widget_Areas
The code they provided can be simply added to your hook function
January 4, 2020 at 8:08 am #1121906byo
Finally i assembled the puzzle lol, i saw your code (in the documentation) and i tought that’s it’s only for adding text not code….Ahhh.. lol
Here is the code i used,
add_action( 'generate_after_archive_description','add_widget_after_archive_description' ); function add_widget_after_archive_description() { ?> <?php if ( is_active_sidebar( 'agp-widget-area-after-description-archives' ) ) : ?> <div id="after-description-sidebar" class="aftr-description-widget-sidebar widget-area" role="complementary"> <?php dynamic_sidebar( 'agp-widget-area-after-description-archives' ); ?> </div><!-- #primary-sidebar --> <?php endif; ?> <?php }
it displays perfectly
Thanks a lot
January 4, 2020 at 12:22 pm #1122079David
StaffCustomer SupportGlad to hear that 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.