How best to specify two-column layout for posts page, one-column for others?

  • Author
    Posts
  • #116168
    Drobb
    Power User

    I’m using a 2-column main-layout setting from Mantra > Layout Settings (the second from the left) and then choosing the one-column, no-sidebar template under WP > Edit Page, Page Attributes > Template, for every page except for my Posts page.

    I’m doing this because Template doesn’t seem to be an option under Page Attributes for the Posts page. This seems to be true across themes.

    If it were an option, I’d choose the One Column, no-sidebar main layout under Mantra > Layout Settings, and then change the Posts page to the two-column template.

    Is there a more efficient way to do what I want to do? Is there any way to enable only my Posts page to use the two-column layout, and have everything else use the one-column layout?

    Thanks much!

    #116275
    Drobb
    Power User

    I added a child theme, using this excellent tutorial, but I’m still at a loss at how best to implement this. Thanks much!

    #116329
    Zed
    Cryout Creations Team

    Hi,

    Mantra does not have built-in support for custom layouts for posts – this functionality only exists for pages using the available page templates.

    Adding custom layouts for posts (all posts or individual posts) would require custom code to detect the site section and override the theme’s computed layout.

    The code responsible for layout decisions is located in includes/custom-styles.php and sidebar.php.


    If you like our creations, help us share by rating them on WordPress.org.
    Please read the available documentation and search the forums before posting.
    #116380
    Drobb
    Power User

    Thank you, Zed! I’m trying to figure this out. As for detecting the site section, this should simply be the page ID, since I’m interested in overriding the theme’s computed layout on that one page in particular, the wordpress-designated Posts page.

    What baffles me is that I can add this line to my child-theme’s functions.php file:
    update_post_meta( N, '_wp_page_template', 'templates/template-twocolumns-right.php' );
    where N = any page except the Posts page, and it will work.

    However, I can go to Mantra > Layout Settings, and change my Posts page to whatever layout I want, as long as I change every single other page on the site along with it. So the Posts page should be able to conform to any of these layouts on its own, shouldn’t it?

    But the Posts page behaves differently than the others, in that unlike all the others, it’s not possible to change this page individually.

    Is that behavior governed by the code in includes/custom-styles.php and sidebar.php?

    #116585
    Drobb
    Power User

    Ok I’m still working on this! By the way, in this post I’ve been saying “Posts Page,” because that’s what it’s called in the WP interface, but I just learned that the technical term for the page I’d like to have a different layout from the rest is my Archive Page.

    So I took a look at archive.php, and I changed these lines

    <?php
         /* Include the Post-Format-specific template for the content.
         * If you want to overload this in a child theme then include a file
         * called content-___.php (where ___ is the Post Format name) and that will be used instead.
         */
         get_template_part( 'content/content', get_post_format() );
    ?>

    to this:

    <?php
         /* Include the Post-Format-specific template for the content.
         * If you want to overload this in a child theme then include a file
         * called content-___.php (where ___ is the Post Format name) and that will be used instead.
         */
         get_template_part( 'content-twocolumns-right.php', get_post_format() );
    ?>

    And then I took templates/template-twocolumns-right.php, renamed it content-twocolumns-right.php, and placed in my child theme folder along with the other files.

    But this had no effect.

    Can anyone tell me what I’m doing wrong, or if I’m even on the right track in solving this problem?

    Many thanks!

    #116634
    Drobb
    Power User

    Ok never mind my last post; I am working on changing the behavior of the “Posts Page,” (set in WP Settings > Reading) not the Archive Page.

Viewing 6 posts - 1 through 6 (of 6 total)

You need to log in to reply to this topic.