Site logo

Archived topic

hook before both sidebars

16 replies · Started by Daniele on June 23, 2016

Viewing posts 1–15 of 17

Currently this isn't possible without some pretty decent custom programming.

I'll play around with it tomorrow morning and will see if I can come up with a solution for you :)

Thank you Tom!

Alright, I believe I have a solution for you :)

First, you would add this function:

add_action( 'generate_sidebars','generate_double_right_sidebar', 0 );
function generate_double_right_sidebar()
{
	?>
	<div class="widget-area grid-50 tablet-grid-50 grid-parent sidebar double-sidebar">
		<div class="inside-double-sidebar">
			Hi there
		</div>
	</div>
	<?php
}

grid-50 is assuming both of your sidebars are set to 25% - 25 x 2 = 50. If your sidebars are set to something else, you'll need to adjust this.

Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

Then you'll need to add this CSS:

.inside-double-sidebar {
    margin-top:20px; /* Separating space value */
    background: #FFF; /* Widget background color value */
    padding: 40px; /* Inside width padding value */
}

Adding CSS: https://generatepress.com/knowledgebase/adding-css/

That should do it :)

mmmm...that code seems working, creating a widget-like area but...how shall I put a widget in it? There's no trace in the admin widget section of a "double sidebar".. how-to?

I need that box just to show the youtube playlist channel widget (not it's the first on top of the right column).

thanks again

It might, but seems to be too complicated for a newbie like me.

Don't worry, I know I've asked more than "support".

Should I mark this topic as resolved?

This part is how you create a widget area which will show up in "Appearance > Widgets":

function alphabet_widgets_init() {

	register_sidebar( array(
		'name'          => 'Home right sidebar',
		'id'            => 'home_right_1',
		'before_widget' => '<aside id="%1$s" class="widget inner-padding %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => apply_filters( 'generate_start_widget_title', '<h4 class="widget-title">' ),
		'after_title'   => apply_filters( 'generate_start_widget_title', '<h4 class="widget-title">' ),
	) );

}
add_action( 'widgets_init', 'alphabet_widgets_init' );

Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

Then your code from above would look something like this:

add_action( 'generate_sidebars','generate_double_right_sidebar', 0 );
function generate_double_right_sidebar()
{
	?>
	<div class="widget-area grid-50 tablet-grid-50 grid-parent sidebar double-sidebar">
		<div class="inside-double-sidebar">
			<?php if ( is_active_sidebar( 'home_right_1' ) ) : ?>
				<?php dynamic_sidebar( 'home_right_1' ); ?>
			<?php endif; ?>
		</div>
	</div>
	<?php
}

Hope that helps out a bit :)

Hi Tom,
thank you very much again.

It works (as you can see) but it shows in every page and It was supposed to be just in the homepage. I added these lines to your code:

add_action( 'generate_sidebars','generate_double_right_sidebar', 0 );
function generate_double_right_sidebar()
{
	?>
	<div class="widget-area grid-35 tablet-grid-35 grid-parent sidebar double-sidebar">
		<div class="inside-double-sidebar">
			<?php if ( is_active_sidebar( 'home_right_1' ) ) : ?>
				<?php dynamic_sidebar( 'home_right_1' ); ?>
                                
<strong><?php if ( is_front_page() ) { ?></strong>

			<?php endif; ?>
		</div>
	</div>
	<?php

but it doesn't work.

Then, I noticed that clicking on the 'Read more button' (+Altro), last posts shown are weird (actually, without box).

Thanks again,
d.

If it needs to only be on the homepage, you can do this:

add_action( 'generate_sidebars','generate_double_right_sidebar', 0 );
function generate_double_right_sidebar()
{
	if ( ! is_front_page() )
		return;

	?>
	<div class="widget-area grid-50 tablet-grid-50 grid-parent sidebar double-sidebar">
		<div class="inside-double-sidebar">
			<?php if ( is_active_sidebar( 'home_right_1' ) ) : ?>
				<?php dynamic_sidebar( 'home_right_1' ); ?>
			<?php endif; ?>
		</div>
	</div>
	<?php
}

Fantastic! :D

Now my 80's site is ready for your showcase page!

You made an incredible job. Why don't you implement the same function in the next upgrade? Don't you think it is really useful?

Thank you, really.

p.s. did you take a look of the other issue I got?

Then, I noticed that clicking on the ‘Read more button’ (+Altro), last posts shown (everywhere, home, pages, archives) are weird (actually, without box).

Is it maybe a known issue you are fixing?

thanks again Tom.

Very strange, the more button loads the posts from the next page, but those posts with no box aren't on the next page of posts: http://www.80s.it/page/2

Maybe you have a plugin causing the issue?

infact...it's the extended feature post plugin that mess up the: it creates a copy of each EFP widget after the content... :(

Perhaps that something they can fix?

If it's something they think needs to be fixed on our end just let me know and I'll look into it :)

No way...that plugin is out of date by 2 years now...but I've found a good replecement: Category Posts Widget

Have a nice day,
D.

This archived topic is closed to new replies.