WordPress.org

Ready to get started?Download WordPress

Forums

template not applied to posts page (3 posts)

  1. miahansen
    Member
    Posted 7 years ago #

    I am using WP as a CMS.
    After creating all the 2 column main static pages, I created a new page called Blog, then I set my Front page as my "Home" page, and Posts page as my "Blog" page in the Options > Reading section. So far so good. But unlike with the main 2 column static pages, I want the blog page to have archives, categories etc displayed somewhere, not to mention I want to add the date etc back to the bottom of posts. So I made a new 3 column template (called "main") and applied that template to the Blog page. But the template is not applied. Did I do something wrong in setting up my Blog page? The same template gets applied just fine to one of the static pages.

    (On a side note, I tried to use variables in the sidebar in order to customize the blog page (rather than applying a template) but got an error on this line:
    <?php if (is_blog()) {?>)

  2. Andrew Ozz
    WordPress Dev
    Posted 7 years ago #

    Is there such thing as is_blog() in WP? There is is_posts_page that you can try.

    Anyway, if you made your own template and assign it to a page, you can pretty much do anything in WP: multiple loops, categories, archives, list by day, month, year, exclude, include, etc. etc. I don't think you need to assign it as the blog front page.

    If not, try using if ($post->ID == 'xx') etc. or print $wp_query and see what you need to use.

  3. miahansen
    Member
    Posted 7 years ago #

    No matter what I tried, a new template would not apply to a posts page. But I got a custom sidebar working instead (with serious professional help).

    1) I made a new sidebar called sidebarblog.php which contains the standard blog page stuff (archives etc). Then called it in index.php AND single.php just above the footer (withing the theme folder):
    <?php get_sidebarblog();?>

    2) Then added this code to general-template.php (in the wp-includeds folder):
    function get_sidebarblog() {
    if ( file_exists( TEMPLATEPATH . '/sidebarblog.php') )
    load_template( TEMPLATEPATH . '/sidebarblog.php');
    else
    load_template( ABSPATH . 'wp-content/themes/default/sidebar.php');
    }

    My big problem now is that I can't bring back the date/categories/comments back to the bottom of the posts on my post page without them also appearing on the main pages. Plus the "Blog" list menu item does not have a current state like the other menu items (grrr). Something to do with a page being set as a "posts page" makes customization very difficult.

Topic Closed

This topic has been closed to new replies.

About this Topic