[Resolved] Customized template means that the Sidebar Layout is ignored

Home Forums Support [Resolved] Customized template means that the Sidebar Layout is ignored

Home Forums Support Customized template means that the Sidebar Layout is ignored

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2041106
    Henry

    I have a customized PHP template for a page that acts as our home page.

    The reason it has been customized is that it has a fairly complex operation with the ACF plugin.

    Anyways – what has happened is that the template defaults to the right-hand side widget column, and if I set it to any other option the sidebar remains where it is…

    If I remove this line:

    do_action( ‘generate_after_primary_content_area’ );
    //generate_construct_sidebars();
    get_footer();

    And comment out the //generate_construct_sidebars(); does that mean that I will force the template to just have one column or should I create a one-page column in the elements option using GeneratePress Pro?

    Thanks! Hope that makes sense…

    Here’s the template:

    <?php
    
    /**
     * Template Name: Home List
     * Template Post Type: page,list
     *
     * @package GeneratePress
    */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    get_header(); ?>
    
    	<div id="primary" <?php generate_do_element_classes( 'content' ); ?>>
    		<main id="main" <?php generate_do_element_classes( 'main' ); ?>>
    
    		<?php
    
    			/**
    			 * generate_before_main_content hook.
    			 *
    			 * @since 0.1
    			 */
    
    			do_action( 'generate_before_main_content' );
    
    			if ( generate_has_default_loop() ) {
    				while ( have_posts() ) :
    
    					the_post();
    
    					generate_do_template_part( 'page' );
    
    				endwhile;
    			}
    
    			/**
    			 * generate_after_main_content hook.
    			 *
    			 * @since 0.1
    			 */
    
    			do_action( 'generate_after_main_content' );
    
    			?>
    
    		<?php
    			$args = [
    			    'post_type'=> 'event-series',
    			    'orderby' => 'meta_value_num',
      				'order' => 'ASC',
    			    'meta_query'=>[
    			        [
    			            'key'=>'event_loop_0_event_start_date',
    			            'compare'=>'EXISTS'
    			        ]
    			    ]
    			];
    
    			$eventsQuery = new WP_Query($args);
    
    			?>
    			<div class="section-event-items inside-article">
    
    					<h2>All Events</h2>
    
    			    <?php
    			        $allEvents=array();
    			        $currentDate=time();
    			        while($eventsQuery->have_posts()):
    
    			        	$eventsQuery->the_post();
    			        	 $mainLink = get_the_permalink();
    
    			        	//$monthYear=
    
    			         	if( have_rows('event_loop') ):
        						while( have_rows('event_loop') ) : the_row();
                                if(strtotime(get_sub_field('event_start_date')) < $currentDate)
                                	continue;
    			        	    $monthYear= date("01-m-Y",strtotime(get_sub_field('event_start_date')));
    			        	       if(!isset($allEvents[$monthYear])){
    			        	       		$allEvents[$monthYear]=array();
    			        	       }
    			        	       $row=get_row(true);
    			        	       $row['mainLink']=$mainLink;
    
    			        	       $allEvents[$monthYear][]= $row;
    
        						endwhile;
    						endif;
    
    			    	endwhile;
    
    			    	 uksort($allEvents, function($a,$b){
    
    								 return strtotime($a) - strtotime($b);
    							});
    
    			    	if(!empty($allEvents)):
    			    		foreach($allEvents as $events):
    			    			 //$month =
    
    							usort($events, function($a,$b){
    								 return strtotime($a['event_start_date']) - strtotime($b['event_start_date']);
    							});
    			    			$eventDate=strtotime($events[0]['event_start_date']);
    			    			 echo '<div class="event-list-wrap"><h2  class="month-name">'.date("F Y",$eventDate).'</h2>';
    			    			 foreach($events as $event):
                                 $event_country = $event['country'];
        							$event_address = "<span class='acf-country-flag-icon famfamfam-flags ".strtolower($event_country['value'])."'></span>".$event_country['label'].' | ';
        							if($event_country['value'] == "US")
        								$event_address.= $event['us_state']['label'].', ';
    
        							$event_address.= $event['city'];
    
    		        				echo  '
    									<div class="event-post-item-row" style="padding-bottom:16px;">
    										<span class="event-title">
    											<a href="'.$event['mainLink'].'" target="_blank">
    											'.$event['event_title'].' </a>
    										</span>
    
    										<br />
    
    										<span class="event-date">
    											'.$event_address.'
    										</span>
    
    										<br />
    
    										<span class="event-date">'.$event['event_start_date'].'</span>
    
    		        					</div>';
    			    			 endforeach;
    			    			 echo '</div>';
    			    		 endforeach;
    			    	else :
    			    	       echo '<div class="no-event-found">Event Not Found </div>';
    			    	endif;
    			    ?>
    
    <!-- https://www.advancedcustomfields.com/resources/taxonomy/ -->
    
    			</div>
    
    		</main>
    
    	</div>
    	<?php
    
    	/**
    	 * generate_after_primary_content_area hook.
    	 *
    	 * @since 2.0
    	 */
    	do_action( 'generate_after_primary_content_area' );
    	generate_construct_sidebars();
    	get_footer();
    #2041384
    David
    Staff
    Customer Support

    Hi there,

    if you remove ( or comment out as you have ) the generate_construct_sidebars(); then you should just have the main content container ie. a single column layout.

    #2042254
    Henry

    Thanks very much

    #2042305
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.