Community Forums › Forums › Archived Forums › Design Tips and Tricks › Placing a widget function inside the breadcrumb
Tagged: Add Widget, filter breadcrumbs
- This topic has 3 replies, 2 voices, and was last updated 8 years, 4 months ago by
mazeymaze.
-
AuthorPosts
-
September 25, 2016 at 2:37 am #193662
mazeymaze
MemberI have been searching for an answer but unfortunately I haven't found it yet, so here is my question.
I want to add the posibility to place a widget inside the breadcrumb. I have a Genesis site with Agentpress Pro theme, and Woocommerce. For this I have added a YITH plugin "add to quote" which also has a small "mini-basket" widget that I would like to place in the right side inside the breadcrumb.
This is what I got so far:
genesis_register_sidebar( array( 'id' => 'breadcrumbwidget', 'name' => __( 'Breadcrumb', 'domain' ), 'description' => __( 'Add Content Here', 'domain' ), ) ); add_action( 'genesis_before_content_sidebar_wrap', 'your_widget' ); function your_widget() { if ( !is_front_page() && is_active_sidebar('breadcrumbwidget') ) { genesis_widget_area( 'breadcrumbwidget', array( 'before' => '<div class="breadcrumbwidget widget-area">', 'after' => '</div>', ) ); }
As you can see the placement "genesis_before_content_sidebar_wrap" is not correct, but I can't seem to find the hook that can add the widget inside the breadcrumb. Is there a hook that does that, or can I define it manually (or place it manually)?
I really hope someone can help me out.
The site is under construction, so a maintenance plugin is activated. You can login a view the page with:
Username: viewer
Password: kuhlmann123321Thanks in advance.
Jens
http://www.kuhlmann-heating.comSeptember 25, 2016 at 3:18 am #193664Brad Dalton
ParticipantUntested but maybe you can filter the breadcrumbs.
You can use this to call the widget.
genesis_widget_area( 'breadcrumbwidget' );
September 25, 2016 at 4:10 am #193665mazeymaze
MemberHi braddalton,
I am not sure that will work - for what I can see the filtering only has to do with the breadcrumb content - I would "simply" like to place a widget in the div-container that holds the breadcrumb.
Like this:
September 25, 2016 at 6:02 am #193667mazeymaze
MemberHi again braddalton,
I have tried to test what you suggested, and maybe it could work (I would just need some more help) 🙂
This is the code I have pasted into my functions file and afterwards added the line of code you suggested to the $args['suffix'] part, so that the code is called at the end of the breadcrumb. It actually shows the widget that I'm after, but it messes up the site totally.
I think you are very close to solving my issue - I hope you will help me out. Just as an extra, the widget does not mess the site up when placed elsewhere, so there must be some sort of failure in what I'm doing when wanting to place it inside this div container.
genesis_register_sidebar( array( 'id' => 'breadcrumbwidget', 'name' => __( 'Breadcrumb', 'domain' ), 'description' => __( 'Add Content Here', 'domain' ), ) ); add_action( 'genesis_do_breadcrumbs', 'your_widget' ); function your_widget() { if ( !is_front_page() && is_active_sidebar('breadcrumbwidget') ) { genesis_widget_area( 'breadcrumbwidget', array( 'before' => '<div class="breadcrumbwidget widget-area" align="right">', 'after' => '</div>', ) ); } } //* Modify breadcrumb arguments. add_filter( 'genesis_breadcrumb_args', 'sp_breadcrumb_args' ); function sp_breadcrumb_args( $args ) { $args['home'] = 'Home'; $args['sep'] = ' / '; $args['list_sep'] = ', '; // Genesis 1.5 and later $args['prefix'] = '<div class="breadcrumb">'; $args['suffix'] = genesis_widget_area( 'breadcrumbwidget' );'</div>'; $args['heirarchial_attachments'] = true; // Genesis 1.5 and later $args['heirarchial_categories'] = true; // Genesis 1.5 and later $args['display'] = true; $args['labels']['prefix'] = 'You are here: '; $args['labels']['author'] = 'Archives for '; $args['labels']['category'] = 'Archives for '; // Genesis 1.6 and later $args['labels']['tag'] = 'Archives for '; $args['labels']['date'] = 'Archives for '; $args['labels']['search'] = 'Search for '; $args['labels']['tax'] = 'Archives for '; $args['labels']['post_type'] = 'Archives for '; $args['labels']['404'] = 'Not found: '; // Genesis 1.5 and later return $args; }
The visual result looks like this:
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.