Support » Theme: Customizr » Custom page with sidebar under page title

  • Resolved Jo Batkin

    (@jobatkin)


    I need to create a custom page template to put the (right) sidebar next to the content with the page header running across both of them at the top.

    The default sidebar layout is to have the page header and content on one side, and the sidebar the same height on the other side.

    I’ve gotten as far as copying custom-page.php over but am a bit unsure how/where I start customising it to make my page layout work and not break any responsiveness.

    Any tips appreciated! Thanks.

Viewing 15 replies - 1 through 15 (of 16 total)
  • I’ve ended up going with a custom widget floated to the right hand side of the page, instead of moving the sidebar.

    For anyone who’s interested, here’s the code I added.

    In my child theme functions.php:

    // Adds a widget area.
    if (function_exists('register_sidebar')) {
        register_sidebar(array(
        'name' => 'Right Contact Area',
        'id' => 'contact-widget',
        'description' => 'Contact area on the right hand side of all pages',
        'before_widget' => '<div class="widget contact-widget">',
        'after_widget' => '</div>',
        'before_title' => '<h2>',
        'after_title' => '</h2>'
        ));
    }
    
    // Place the widget area after the content header, for all pages except home
    add_action ('__after_content', 'add_contact_widget_area', 0);
    function add_contact_widget_area() {
        if (function_exists('dynamic_sidebar') && !is_front_page()) {
        	dynamic_sidebar('Right Contact Area');
        }
    }

    and then in my child theme style.css:

    .home .entry-content { width: 100%; float: none; }
    .entry-content { width: 70%; float: left; }
    .contact-widget { width: 319px; margin-left: 20px; float: right; }

    What about moving headings above main container:
    HEADINGS
    CONTENT – SIDEBAR
    ….
    ?
    If you like this idea…
    Your custom-page.php will have to look like this (I copy just the relevant part here):

    <?php
    /*
    Template Name: Page with headings above main container
     */
    remove_action( '__before_content', array( TC_headings::$instance,  'tc_content_headings') );
    add_action( '__before_main_container', array( TC_headings::$instance, 'tc_content_headings') );
    ?>
    .....REST OF THE CUSTOM PAGE TEMPLATE CODE .....

    Hope this helps

    Great idea, thanks! i think that would work well, but my current solution is also working so hopefully someone else will be able to use it.

    Thanks.
    I think would be better to mark this topic as resolved, so people can see that… “there’s a hope” :D, don’t you think?

    sure!

    also do you know where there’s a list of all of the hooks you can use with Customizr? e.g., __before_content, __before_main_container, etc. I have been looking but without any luck so far and it would really be useful.

    No sorry, don’t know if there’s this list.

    Thanks anyway. I appreciate your replies.

    do you know where there’s a list of all of the hooks you can use with Customizr?

    Dave was going to do it, then I said I’d take a look, but the real world keeps intervening. In the meantime, the easiest way I know to find filters is to search inside all the Customizr files for apply_filters.

    and do_action

    Nic did agree to do it (sorry to pass the buck) but there is a release due this month so as you say, priorities. If @jo sends me an email, I can send her what I’ve done to date.

    Moderator Jan Dembowski

    (@jdembowski)

    Brute Squad and Volunteer Moderator

    Jo? Please excuse me while I go off topic for a minute.

    @rdellconsulting? Please do not again post your email address on these forums or attempt to contact anyone off forum that way again.

    That is not a judgement against you or your behavior but as you are aware that is actively discouraged and not allowed for reasons that have been discussed not that long ago.

    http://make.wordpress.org/updates/2014/01/31/support-team-update-for-january-30th/

    It’s the item labled “Contacting people off forum”, you can’t miss it. So please do not do that.

    My mistake Jan, many apologies

    d4z_c0nf:

    I am also trying to use your code, to move my page header outside of the page wrapper to allow it to be full width. Unfortunately the remove/add action code, either the top of my page template, or in my child theme functions.php, doesn’t seem to do anything. This is what I’ve got:

    remove_action( '__before_content', array( TC_headings::$instance,  'tc_content_headings') );
    add_action( '__before_main_wrapper', array( TC_headings::$instance, 'tc_content_headings') );

    and it neither removes the existing heading nor adds the new one to the new place.

    Is it something to do with using a static instance of TC_headings instead of $this, as used when defining it in class-content-headings.php do you think?

    Has anyone else had success moving the heading around like this?
    Wasn’t sure if I should start a new topic or not, since I’m referring to a reply.

    Hi, I said to put that in a page template, ’cause I was replying to

    I need to create a custom page template to put…

    , so I thought you wanted a custom page template.. 😀
    If you want to use that in your child theme functions.php, do this:

    add_action('wp_head', 'move_content_headings');
    function move_content_headings(){
        remove_action( '__before_content', array( TC_headings::$instance,  'tc_content_headings') );
        add_action( '__before_main_wrapper', array( TC_headings::$instance, 'tc_content_headings') );
    }

    Hope this helps.

    I only tried to put it in functions.php because it wasn’t doing anything in the custom page template 🙂

    That code in functions.php is removing the heading from the content, but is not adding it before the main wrapper.

    If I replace ‘__before_main_wrapper’ with ‘__before_main_container’ then the heading is back, and has been moved out of the main content loop, but is still within the page wrapper so it doesn’t get full width.

    Lastly I tried using add_action( '__after_header', array( TC_headings::$instance, 'tc_content_headings') ); which finally worked! 😀 My page heading is now outside of the main page wrapper, full width across the page, and I have a right sidebar widget.

    Thanks to all for your help.

    I also found it very useful to search the Customizr code for ‘add_action’ to find a list of hooks.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Custom page with sidebar under page title’ is closed to new replies.