hook before both sidebars

Home Forums Support hook before both sidebars

Home Forums Support hook before both sidebars

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #204159
    Daniele

    Here I come again πŸ˜€

    Is there any chance to see implemented a hook before both sidebars?

    like this:

    http://www.80s.it/pic/Untitled-11.jpg

    #204214
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #204252
    Daniele

    Thank you Tom!

    #204337
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #204492
    Daniele

    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

    #204508
    Tom
    Lead Developer
    Lead Developer
    #204559
    Daniele

    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?

    #204619
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #204767
    Daniele

    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.

    #204786
    Tom
    Lead Developer
    Lead Developer

    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
    }
    #204993
    Daniele

    Fantastic! πŸ˜€

    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.

    #205001
    Tom
    Lead Developer
    Lead Developer

    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?

    #205254
    Daniele

    infact…it’s the extended feature post plugin that mess up the: it creates a copy of each EFP widget after the content… πŸ™

    #205280
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #205383
    Daniele

    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.

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.