badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

Possible to have a second business page (with different widget pages)??

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #3439
    shawnhoffman
    Participant

    I really like the layout for the business page, and I am using it on my homepage for an upcoming website (shawn.mcctraduccion.com) but I want to know if I can also have a second page using the same format, but with different links.

    I’ll explain- on the home page, you see the services from the widget as Translation and English Classes… then if you click on What ShawnCanDo > Student Visa Processes you will see another instance of the services widget, with Translation and English classes… I’d like to have different links there- NOT Translation and English classes… maybe there is a way to make a second widget, or a clone of the business page template and then put the widget on that one? I am pretty new to WP but please let me know if it’s possible and I can try to do it step by step.

    Thanks so much!

    -Shawn

    #3441
    shawnhoffman
    Participant

    Well – I think I figured it out. I will describe how I did it, and others can comment if that sounds right, if I am going to run into problems, etc…

    1. Copy of page-template-business.php and change file name to page-template-business2.php
    2. –> Change all instances of ‘business’ – to ‘business2’

    3. Copy code in attitude_widgets.php relative to ‘Registering Business Page template sidebar’
    4. –> Change all instances of ‘business’ – to ‘business2’ in the copied section

    5. Same thing with content-extensions.php

    Seems to be working (http://shawn.mcctraduccion.com).

    You can see that if you click on ‘What ShawnCanDo’ > ‘Student Visa Processes’ you are taken to a page where you see the 3 services (NIE/TIE, NIE renewal, autorizacion…). Which is from the 2nd widget, and different from the services on the home page.

    If anybody can see why this would be a problem, or if there are any other files that I would need to edit, PLEASE TELL ME! If not, I hope this is useful for somebody else!

    -Shawn

    #3477
    Sanjip Shah
    Participant

    @shawnhoffman All you have done is good. But please make a child theme to make this customization so that you won’t lose the changes when you update the theme.

    #3499
    shawnhoffman
    Participant

    Cool! Thanks!

    #3501
    shawnhoffman
    Participant

    So, I am learning about child themes – and I See to add:

    require_once( get_stylesheet_directory() . '/my_included_file.php' );

    To the style.css of the child theme.

    In this case, it will be page-template-business2.php, attitude_widgets.php, & content-extensions.php

    Do I need to put them in the corresponding subdirectories, or just into the theme directory.
    i.e. do the files need to be

    /attitude-child/page-template-business2.php
    /attitude-child/library/widgets/attitude_widgets.php
    /attitude-child/library/structure/content-extensions.php

    or simply

    /attitude-child/page-template-business2.php
    /attitude-child/attitude_widgets.php
    /attitude-child/content-extensions.php

    Thanks!

    #3503
    shawnhoffman
    Participant

    Ufff now I am having problems…

    You can see what it looks like now at the same site…

    I put the files in their respective folders, which seems right…

    However, I am not sure if the files

    a) need to be edited more to reflect “attitude-child” and not “attitude”
    b) need to be the whole file with my additions, or only the new additions

    HELP?!?! Thank you!!

    #3505
    shawnhoffman
    Participant

    Well, I think that require line doesn’t go in the style.css file – but rather is php … but I still don’t know where/how to do it 🙁

    #3506
    shawnhoffman
    Participant

    Wow that was such a long process of trying, failing, changing and repeating, but with almost no experience with php and never having used functions.php or anything with child themes I think I finally figured it out. Please let me know if I “overcorrected” or did something wrong or still need to do something. Seems to be functioning at this point.

    For the page_template_business2.php, it was sufficient to only put it in the child theme directory.

    For the other two, I created functions.php in the child theme and added the necessary code below. My questions that remain:

    1) Was it necessary to remove the action, and add a new one, or could I have added to the existing action? From what I read, it was necessary to delete the old stuff, but then copy them into the new action in order to maintain the other native widgets.

    2) Was it necessary to name the function _child or could I have not done that?

    3) Was there any use for that require_once line?? Cause I deleted it and don’t see where it would be necessary.

    Here’s the code from functions.php and I obviously deleted all the other junk from my previous posts.

    <?php
    
    remove_action( 'widgets_init', 'attitude_widgets_init' );
    
    function attitude_child_widgets_init() {
    
    	// Registering main left sidebar
    	register_sidebar( array(
    		'name' 				=> __( 'Left Sidebar', 'attitude' ),
    		'id' 					=> 'attitude_left_sidebar',
    		'description'   	=> __( 'Shows widgets at Left side.', 'attitude' ),
    		'before_widget' 	=> '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  	=> '</aside>',
    		'before_title'  	=> '<h3 class="widget-title">',
    		'after_title'   	=> '</h3>'
    	) );
    
    	// Registering main right sidebar
    	register_sidebar( array(
    		'name' 				=> __( 'Right Sidebar', 'attitude' ),
    		'id' 					=> 'attitude_right_sidebar',
    		'description'   	=> __( 'Shows widgets at Right side.', 'attitude' ),
    		'before_widget' 	=> '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  	=> '</aside>',
    		'before_title'  	=> '<h3 class="widget-title">',
    		'after_title'   	=> '</h3>'
    	) );
    
    	// Registering Business Page template sidebar
    	register_sidebar( array(
    		'name' 				=> __( 'Business Page Sidebar', 'attitude' ),
    		'id' 					=> 'attitude_business_page_sidebar',
    		'description'   	=> __( 'Shows widgets on Business Page Template. Sutiable widget: Theme Horse: Featured widget, Theme Horse: Testimonial, Theme Horse: Services', 'attitude' ),
    		'before_widget' 	=> '<section id="%1$s" class="widget %2$s">',
    		'after_widget'  	=> '</section>',
    		'before_title'  	=> '<h1 class="widget-title">',
    		'after_title'   	=> '</h1>'
    	) );
    
    // Registering Business2 Page template sidebar
    	register_sidebar( array(
    		'name' 				=> __( 'Business2 Page Sidebar', 'attitude' ),
    		'id' 					=> 'attitude_business2_page_sidebar',
    		'description'   	=> __( 'Shows widgets on Business2 Page Template. Sutiable widget: Theme Horse: Featured widget, Theme Horse: Testimonial, Theme Horse: Services', 'attitude' ),
    		'before_widget' 	=> '<section id="%1$s" class="widget %2$s">',
    		'after_widget'  	=> '</section>',
    		'before_title'  	=> '<h1 class="widget-title">',
    		'after_title'   	=> '</h1>'
    	) );
    
    	// Registering contact Page sidebar
    	register_sidebar( array(
    		'name' 				=> __( 'Contact Page Sidebar', 'attitude' ),
    		'id' 					=> 'attitude_contact_page_sidebar',
    		'description'   	=> __( 'Shows widgets on Contact Page Template.', 'attitude' ),
    		'before_widget' 	=> '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  	=> '</aside>',
    		'before_title'  	=> '<h3 class="widget-title">',
    		'after_title'   	=> '</h3>'
    	) );
    
    	// Registering footer sidebar
    	register_sidebar( array(
    		'name' 				=> __( 'Footer Sidebar', 'attitude' ),
    		'id' 					=> 'attitude_footer_sidebar',
    		'description'   	=> __( 'Shows widgets at footer.', 'attitude' ),
    		'before_widget' 	=> '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  	=> '</aside>',
    		'before_title'  	=> '<h3 class="widget-title">',
    		'after_title'   	=> '</h3>'
    	) );
    
    	// Registering widgets
    	register_widget( "attitude_custom_tag_widget" );
    	register_widget( "attitude_service_widget" );
    	register_widget( "attitude_recent_work_widget" );
    	register_widget( "attitude_Widget_Testimonial" );
    	
    }
    
    add_action( 'widgets_init', 'attitude_child_widgets_init' );
    
    add_action( 'attitude_business2_template_content', 'attitude_business2_template_widgetized_content', 10 );
    /**
     * Displays the widget as contents
     */
    function attitude_business2_template_widgetized_content() { ?>
    	<div id="content">
    		<?php if( is_active_sidebar( 'attitude_business2_page_sidebar' ) ) {
    
    			// Calling the footer sidebar if it exists.
    			if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( 'attitude_business2_page_sidebar' ) ):
    			endif;
    		}
    		?>
    	</div><!-- #content -->
    <?php
    }
    
    ?>
    #3613
    Sanjip Shah
    Participant

    @shawnhoffman All you have done is perfect. You could also do as follows as another way. Just add your new sidebar only in the functions.php file without removing the parent sidebars, widgets and again adding them. Try this out as well and see if this works.

    Q1) If you do like this then you don’t have to remove the action and again add it. Adding the code below will just append your new sidebar.
    Q2) Adding _child is just a way to use a different function name, if you use the same function name attitude_widgets_init in the child theme then their will be same function definition in two places one in parent theme and one in child theme. This function is not pluggable function so adding this in child theme will not overwrite the parent function. So, using same name in this case will cause problem.
    Q3) Require once code will be unnecessary after you do as you done now.

    <?php;
    
    function attitude_child_widgets_init() {
    
    // Registering Business2 Page template sidebar
    	register_sidebar( array(
    		'name' 				=> __( 'Business2 Page Sidebar', 'attitude' ),
    		'id' 					=> 'attitude_business2_page_sidebar',
    		'description'   	=> __( 'Shows widgets on Business2 Page Template. Sutiable widget: Theme Horse: Featured widget, Theme Horse: Testimonial, Theme Horse: Services', 'attitude' ),
    		'before_widget' 	=> '<section id="%1$s" class="widget %2$s">',
    		'after_widget'  	=> '</section>',
    		'before_title'  	=> '<h1 class="widget-title">',
    		'after_title'   	=> '</h1>'
    	) );	
    }
    
    add_action( 'widgets_init', 'attitude_child_widgets_init' );
    
    add_action( 'attitude_business2_template_content', 'attitude_business2_template_widgetized_content', 10 );
    /**
     * Displays the widget as contents
     */
    function attitude_business2_template_widgetized_content() { ?>
    	<div id="content">
    		<?php if( is_active_sidebar( 'attitude_business2_page_sidebar' ) ) {
    
    			// Calling the footer sidebar if it exists.
    			if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( 'attitude_business2_page_sidebar' ) ):
    			endif;
    		}
    		?>
    	</div><!-- #content -->
    <?php
    }
    
    ?>
    #5252
    siredgar
    Participant

    is it possible to have a third business page? please could you tell me what the code forthe functions.php will be? I have tried having the code above twice, once for business2 and once for business3 along with adding the page-template-business2.php and page-template-business3.php files but it only shows business2 widget. Thank you!

    #5297
    Sanjip Shah
    Participant

    @siredgar If you repeat the above mentioned process for the third time properly then yes you can have the third business page as well. Please paste the code that you have added in the functions.php and I will look into it if there are any issues.

    #5308
    siredgar
    Participant

    Thanks Sanjip, I have managed to get it working using the following in the functions.php of the childtheme. I had the order wrong before, seems to be correct now? Thank you

    <?php;
    
    function attitude_child_widgets_init() {
    
    // Registering Business2 Page template sidebar
    	register_sidebar( array(
    		'name' 				=> __( 'Business2 Page Sidebar', 'attitude' ),
    		'id' 					=> 'attitude_business2_page_sidebar',
    		'description'   	=> __( 'Shows widgets on Business2 Page Template. Sutiable widget: Theme Horse: Featured widget, Theme Horse: Testimonial, Theme Horse: Services', 'attitude' ),
    		'before_widget' 	=> '<section id="%1$s" class="widget %2$s">',
    		'after_widget'  	=> '</section>',
    		'before_title'  	=> '<h1 class="widget-title">',
    		'after_title'   	=> '</h1>'
    	) );	
    }
    
    {
    
    // Registering Business3 Page template sidebar
    	register_sidebar( array(
    		'name' 				=> __( 'Business3 Page Sidebar', 'attitude' ),
    		'id' 					=> 'attitude_business3_page_sidebar',
    		'description'   	=> __( 'Shows widgets on Business3 Page Template. Sutiable widget: Theme Horse: Featured widget, Theme Horse: Testimonial, Theme Horse: Services', 'attitude' ),
    		'before_widget' 	=> '<section id="%1$s" class="widget %2$s">',
    		'after_widget'  	=> '</section>',
    		'before_title'  	=> '<h1 class="widget-title">',
    		'after_title'   	=> '</h1>'
    	) );	
    }
    
    add_action( 'widgets_init', 'attitude_child_widgets_init' );
    
    add_action( 'attitude_business2_template_content', 'attitude_business2_template_widgetized_content', 10 );
    /**
     * Displays the widget as contents
     */
    function attitude_business2_template_widgetized_content() { ?>
    	<div id="content">
    		<?php if( is_active_sidebar( 'attitude_business2_page_sidebar' ) ) {
    
    			// Calling the footer sidebar if it exists.
    			if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( 'attitude_business2_page_sidebar' ) ):
    			endif;
    		}
    		?>
    	</div><!-- #content -->
    
    add_action( 'attitude_business3_template_content', 'attitude_business3_template_widgetized_content', 10 );
    /**
     * Displays the widget as contents
     */
    function attitude_business3_template_widgetized_content() { ?>
    	<div id="content">
    		<?php if( is_active_sidebar( 'attitude_business3_page_sidebar' ) ) {
    
    			// Calling the footer sidebar if it exists.
    			if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( 'attitude_business3_page_sidebar' ) ):
    			endif;
    		}
    		?>
    	</div><!-- #content -->
    
    <?php
    }
    
    ?>
    
    #5344
    Sanjip Shah
    Participant

    @siredgar Okay. Great.

    #5360
    siredgar
    Participant

    @sanjip-shah Hi Sanjip, The code unfortunately displays the business3 links on the business2 page. Is there a problem with the php above? thank you!

    #5361
    Sanjip Shah
    Participant

    @siredgar Did you create this file page_template_business3.php and write the corresponding code. Please paste the complete code of this file and I will look into it.

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