• Hi!

    I have the Twenty Eleven theme. On my startpage I have a “blog-layout” so when I write a new “post” it will be on my startpage. Can I get the bloglayout on the other sites on my page like the startpage?

    Thanks!

Viewing 15 replies - 1 through 15 (of 22 total)
  • obviously, you will have the ‘same’ layout on archive pages;
    but if you refer to having other pages to show multiple posts in the same layout as the front page, then you possibly need to create page templates: https://codex.www.ads-software.com/Pages#Page_Templates

    also, please don’t edit twenty eleven directly; create a child theme and work with that: https://codex.www.ads-software.com/Child_Themes
    it is very important to have an unedited default theme in case of all kinds of theme problems.

    Thread Starter Gustav820

    (@gustav820)

    Ok thanks for the info. Ive created a childtheme ??
    But a pagetemplate seems to advanced for me ??
    You know if there is a plugin for that? So you can use the bloglayout on one page?

    use the bloglayout on one page?

    there is no plugin for this.

    there will probably be two steps neccessary:

    a:
    – create a page template:

    make a coy of sidebar-page.php; save it as blog-page.php.
    edit blog-page.php and change this line:
    * Template Name: Sidebar Template
    to:
    Template Name: Blog Layout Page

    then change this line:
    <?php get_template_part( 'content', 'page' ); ?>
    to:
    <?php get_template_part( 'content', 'index' ); ?>

    in functions.php of the child theme, add:

    add_filter('body_class', 'allow_sidebar_on_template', 20, 2);
    function allow_sidebar_on_template($wp_classes, $extra_classes) {
    if( is_page_template( 'blog-page.php' ) ) : // Filter the body classes
        foreach($wp_classes as $key => $value) {
        if ($value == 'singular') unset($wp_classes[$key]);
        }
    endif;
    return array_merge($wp_classes, (array) $extra_classes);
    }

    https://www.ads-software.com/support/topic/twenty-eleven-making-a-new-page-template-from-existing-page-template?replies=5

    b:
    – define a custom query to be added.
    https://codex.www.ads-software.com/Function_Reference/query_posts

    this part depends on what you want to filter/show on that page.

    Thread Starter Gustav820

    (@gustav820)

    Thank you very much! ?? very kind.

    Thread Starter Gustav820

    (@gustav820)

    It didnt work. ??
    Maybe I’m doing something wrong.

    I have created the blog-page.php, with the code, and placed it in my childfolder.

    Then should I just copy function.php to my childfolder and add the lines? Or should it be empty and then add the code (add_filter(‘body_class’…).

    What should I do next? ??

    Thanks for your help!

    Thread Starter Gustav820

    (@gustav820)

    Ohh cool I got the bloglayout to work out ??
    But how do I post different stuff to that specifik page?

    Thread Starter Gustav820

    (@gustav820)

    I would be very happy if anyone know how to help me with this! ?? Thanks!!

    But how do I post different stuff to that specifik page?

    in the blog-page.php, before this line:

    <?php get_template_part( 'content', 'index' ); ?>

    add a custom query;

    example:

    <?php query_posts('cat=7'); ?>

    (what to add into the query depends on your idea of ‘different stuff’)
    see:
    https://codex.www.ads-software.com/Function_Reference/query_posts

    and after the line:

    <?php get_template_part( 'content', 'index' ); ?>

    add:

    <?php wp_reset_query(); ?>

    Thread Starter Gustav820

    (@gustav820)

    Ok thanks! It doesnt work. The Blogpage looks strange (not like the startpage) and it doesn’t show the posts. If I make a new post, should I write something special in it so it will show on the blogpage?

    Here is how the blog-page.php code looks like:

    [code moderated - please follow https://codex.www.ads-software.com/Forum_Welcome#Posting_Code for posting code]

    The Blogpage looks strange (not like the startpage) and it doesn’t show the posts.

    can you post a link to your site, to illustrate what your front page looks like, and how the blog page turned out?

    EDIT:
    partly my mistake; i didn’t check exactly how page.php looked like.
    try this in the core of blog-page.php:

    <div id="primary">
    			<div id="content" role="main">
    
    				<?php query_posts('cat=0'); ?>
                           <?php if(have_posts()) : while(have_posts() ) : the_post();
    				<?php get_template_part( 'content', 'index' ); ?>
    
    				<?php endwhile; endif; ?>
    
    			</div><!-- #content -->
    		</div><!-- #primary -->

    END of EDIT

    what to add into the query depends on your idea of ‘different stuff’

    take a moment, and define and describe what you want to show as ‘different stuff’.

    also, read the codex about ‘query_posts()’ to get an idea what parameters you could use.

    Thread Starter Gustav820

    (@gustav820)

    LOL The page got messed up…
    The only thing I want is the startpage as it is with the bloglayout. I have a page on the menu called ‘News’. I would like to have the same design on the News page as the startpage. So if I post something new and put it in the News category it should show on the News page.

    You would make my day if you could post the script here for blog-page.php. I only messing it up.
    Thank you for helping me. ??

    Thread Starter Gustav820

    (@gustav820)

    Here is how blog-page.php looks like:
    https://pastebin.com/Vpy2DzzM

    If I surf to the News site now I only get “page cannot display”

    If I surf to the News site now I only get “page cannot display”

    can you post a link to your page?
    without seeing the page, any further suggestions are limited.

    for the query, try to change this line:

    <?php query_posts('cat=0'); ?>

    to:

    <?php query_posts('category_name=news&posts_per_page=-1'); ?>
    Thread Starter Gustav820

    (@gustav820)

    Of course:
    https://sunformymind.vacau.com/
    The page is empty because I wanna make the Newsblogpage first ??
    Thanks

    the error is my mistake, from this section – shown fixed below:

    <?php query_posts('cat=0'); ?>
                  <?php if(have_posts()) : while(have_posts() ) : the_post(); ?>
                  <?php get_template_part( 'content', 'index' ); ?>

    (the closing php tag ?> was missing after ...the_post(); )

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘Twenty Eleven post vs sites?’ is closed to new replies.