• I set a static homepage and my blog at mysite.com/blog/

    I created a template called blog and a page with the slug URL of mysite.com/blog/ and assigned the blog template.

    When this was working I had my permalink structure at /blog/%postname%/

    For some reason the code I have to display excerpts in the blog template is no longer working. The template is displaying however.

    I can’t remember where I got the code to output post excerpts for this template.

    Here’s the code that I have. Forgive the extra markup:

    <?php
    /*
    Template Name: Blog
    */
    
    // Which page of the blog are we on?
    $paged = get_query_var('paged');
    query_posts('cat=-0&paged='.$paged);
    
    // make posts print only the first part with a link to rest of the post.
    global $more;
    $more = 0;
    
    //load index to show blog
    load_template(TEMPLATEPATH . '/blog.php');
    ?>
    <?php get_header(); ?>
    
    <div class="container_24 wrap-row clearfix">
      <div class="grid_16">
        <h1>My Blog</h1>
        <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
        <article class="excerpt media"> <a class="img" href="<?php the_permalink() ?>">
          <?php
    			//This must be in one loop
    
    			if(has_post_thumbnail()) {
    				the_post_thumbnail("thumbnail-s-c");
    			} else {
    				echo get_avatar( $id_or_email = get_the_author_meta('user_email'), $size = '100', $default = '<path_to_url>' );
    			}
    			?>
          </a>
          <div class="bd">
            <h2 class="title h4"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
              <?php the_title(); ?>
              </a></h2>
            <?php the_excerpt(); ?>
          </div>
        </article>
        <?php endwhile; else: ?>
        <p>Sorry, no posts we're found.</p>
        <?php endif; ?>
        <p>
          <?php posts_nav_link(); ?>
        </p>
      </div>
      <div class="grid_8">
        <?php get_sidebar('blog'); ?>
      </div>
    </div>
    <?php get_footer(); ?>

    You’ll notice I’m outputting some markup and image thumbs for styling.

    Am I doing something wrong and did something change that makes this technique no longer work

Viewing 15 replies - 1 through 15 (of 18 total)
  • The only “odd” thing that I see is the query_posts – what happens if you comment that out?

    Based on the code pasted – there really isn’t a reason to re-do the query. Paging should be already handled.

    You might also want to reset your Permalinks. Go to Settings -> Permalinks. Change to default, SAVE, and then back to your preferred setting.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    πŸ³οΈβ€πŸŒˆ Advisor and Activist

    Is wordpress installed in a folder called blog, or did you make a page called blog?

    Logically that would make your urls domain.com/blog/blog/%postname% if WP is actually IN the blog folder…

    Thread Starter mattmikulla

    (@mattmikulla)

    Ipstenu no, my installation is not in a folder called blog.

    I just want a static index page and my blog and all posts to be located off of /blog/

    Thread Starter mattmikulla

    (@mattmikulla)

    transom I tried commenting out

    query_posts('cat=-0&paged='.$paged);

    and changed my permalink to default and then back.

    Didn’t work. Hummmm??

    Thread Starter mattmikulla

    (@mattmikulla)

    I am trying to use the instructions here:

    http://codex.wordpress.org/Making_Your_Blog_Appear_in_a_Non-Root_Folder

    But they appear to not be working or they are outdated.

    Matt

    Ignore that page. Its wrong. You shouldn’t need to include a file or call query_posts at all.

    First you are going to want to read this. However, I have a feeling you already have that down pat.

    Next you are going to want to create a page template with this guide. make sure it includes a simple loop. The example on that page is perfect.

    Make sure that the “blog” page is using the template that you created. That’s it.

    Thread Starter mattmikulla

    (@mattmikulla)

    Thanks Joe. Something is still up.

    The problem or solution happens at the reading settings selection at front page and posts page.

    When in reading settings
    front page = front
    posts page = blog

    posts display fine however the template I created blog.php isn’t being used. Instead, index.php is being used even though at the page I created for the blog mysite.com/blog/ has the blog template selected.

    When in reading settings
    front page = front
    posts page = select (undefined)

    posts do not display but the blog.php template is being used.

    The instructions referenced above state that a custom template should not be used to create a blog page

    Title the second page “Blog” (or you could call it “News”, “Articles”, etc.). This page will be a place-holder for showing the Posts on your site.

    Do not use a custom Page template for this page! home.php or index.php will be used to generate this page.
    DO NOT add content to the Blog Page. Leave it blank. Any content here will be ignored — only the Title is used.
    Publish the Page.

    So I am currently limited to the index.php template. I would prefer to use a custom blog front page template that is different than the index.php template to keep it out of the natural cascade of template calling.

    Any ideas?

    The template for the main blog page is usually home.php

    and as Joe Hall and I both suggested, ignore that other page.

    Thread Starter mattmikulla

    (@mattmikulla)

    Got it. However, I would like to output custom content written on the blog page that I can update and edit any time without hardcoding a template. (This is my blog blah blah blah).

    Since it seems to be forbidden are there easy workarounds?

    DO NOT add content to the Blog Page. Leave it blank. Any content here will be ignored — only the Title is used.

    Custom Field, Excerpts, etc?

    You don’t necessarily have to make a template. If you create the pages and set them in Settings > Reading your blog page will most likely use index.php, or home.php if you have one. If you are happy with that, you’re done. If you want your blog page to display differently without changing index.php, you only have to make a template once. Updating your blog posts has nothing to do with which theme you are using.

    You could use a sticky post, it will stay at the top of thr blog.

    If what you are saying is that you want to have text above the blog posts that you can change from time to time and style separately, you can code a php include into the theme and keep that text & code in a separate file, or if you want to get crazy you could store that text in a custom post type and use multiple loop code to display that before your regular posts. That would allow you to use the WP editor to edit that text.

    Thread Starter mattmikulla

    (@mattmikulla)

    Jonas, your last post addresses what I am trying to achieve.

    Include easily editable text on my blog page.

    The php include is a step in the right direction but I would prefer to not create an include for this purpose. For example, I wouldn’t want a client having to go through this.

    I’m going to test the custom field route.

    Yes you may also be able to use a Custom Field on the page and use code to display that, but for the record, also look at Custom Post Types, which might give you more versatility.

    Jonas, If all Matt wants is a changable message at the top of the blog, I’m interested to know why the sticky post won’t do the trick, seems so much easier than custom posts and feilds and extra loops. Perhaps there’s something I can learn here for myself and to pass on.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Blog Off Index With It's Own Directory Broken After WordPress Update?’ is closed to new replies.