WordPress.org

Ready to get started?Download WordPress

Forums

Customizr
[resolved] Custom page with sidebar under page title (17 posts)

  1. Jo Batkin
    Member
    Posted 4 months ago #

    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.

  2. Jo Batkin
    Member
    Posted 4 months ago #

    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; }
  3. d4z_c0nf
    Member
    Posted 4 months ago #

    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

  4. Jo Batkin
    Member
    Posted 4 months ago #

    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.

  5. d4z_c0nf
    Member
    Posted 4 months ago #

    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?

  6. Jo Batkin
    Member
    Posted 4 months ago #

    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.

  7. d4z_c0nf
    Member
    Posted 4 months ago #

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

  8. Jo Batkin
    Member
    Posted 4 months ago #

    Thanks anyway. I appreciate your replies.

  9. ElectricFeet
    Member
    Posted 4 months ago #

    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.

  10. d4z_c0nf
    Member
    Posted 4 months ago #

    and do_action

  11. rdellconsulting
    Member
    Posted 4 months ago #

    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.

  12. 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.

  13. rdellconsulting
    Member
    Posted 4 months ago #

    My mistake Jan, many apologies

  14. Jo Batkin
    Member
    Posted 4 months ago #

    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.

  15. d4z_c0nf
    Member
    Posted 4 months ago #

    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.. :D
    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.

  16. Jo Batkin
    Member
    Posted 4 months ago #

    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! :D 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.

  17. d4z_c0nf
    Member
    Posted 4 months ago #

    Ops, I failed to copy the second snippet, I copied yours and not mine.
    In the first snippet I wrote __before_main_container. And I wrote that because of your request:

    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.

    And yes it put the heading inside the main-wrapper container.

    You changed it to "__before_main_wrapper".

    Don't know why it didn't work in your custom page template, to me works (both with __before_main_wrapper and __before_main_container). But I cannot see your code so.. cannot say anything.

    Also, add an action to the hook __before_main_wrapper if you assign a priority (all except 10) works also in functions.php . And about that, I have to admit that I don't understand why :D

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.