WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Loop.php editing for main blog page help needed

[Resolved] Loop.php editing for main blog page help needed

  • I’m trying to edit a site someone else created.

    The loop code is in the index.php page and is apparently working, because the main blog page renders with 3 posts as it’s set, but I can’t get it to show content or excerpts.

    The blog main page is here
    .

    Below is the code on loop.php which I know works, because I added the link to the title which is working and I put paragraph tags around the code that should give me the excerpt, but it doesn’t render, though it did add some space.

    ` <!–post –>
    <div class=”post”>
    <a href=”<?php the_permalink();?>”><h6><?php the_title();?></h6></a>
    <div class=”meta-post”>Posted on <?php echo get_the_date();?> | <?php the_author_meta( ‘first_name’); ?> <?php the_author_meta( ‘last_name’); ?> </div>
    <p><?php if ( is_category() || is_archive() ) {
    the_excerpt();
    } else {
    the_content();
    } ?></p> <p><a href=”<?php the_permalink();?>”>read more >></a></p>
    </div>
    <!–post –>`

    I appreciate any help someone can give.

Viewing 5 replies - 1 through 5 (of 5 total)
  • I would suggest that you change

    <p><?php if ( is_category() || is_archive() ) {
    the_excerpt();
    } else {
    the_content();
    } ?></p>

    into

    <?php the_content(); ?>

    and to see is that working. If it is, try changing it to

    <?php if ( is_category() ) {
    the_excerpt();
    { else }
    the_content();
    }

    and so on, until you find what is breaking your code/

    Yes, I had tried that. It’s set back to that now and you can see that it’s not working. Any other suggestions?

    I just noticed something, but i don’t know is it that. Can you delete

    | <?php the_author_meta( 'first_name'); ?> <?php the_author_meta( 'last_name'); ?>

    that part of the loop? If you look at your site, that info is not displayed. Maybe that’s the problem. But as far as i can see, your code should work fine.

    I deleted that part. No change. Thanks for trying, but I still need to figure this out.

    Why would <?php the_content(); ?> not work?

    Here is the index.php code which is where the loop.php code goes to post to the blog’s main page. The <!--page --> part of this page actually seems to change the page that the blog links go to when you click the “read more” links. I changed the header size in that code and it changed on those blog pages, though those pages don’t say “Read more…” at the bottom as it says in the code; they say “Return >>”. Please let me know if something in this code might be the problem or if we need to look at something else. Thanks!:

    <?php get_template_part(‘./template/header’);?>
    <body class=”inner-page”>
    <div id=”outer-wrapper”>
    <?php get_template_part(‘./template/navigation’);?>
    <div id=”wrapper”>
    <!–header–>
    <div id=”header”>
    <!–blog title –>
    <div class=”blog-title”>
    <img src=”<?php bloginfo(‘template_directory’);?>/images/new/kowabunga_masthead.jpg” alt=”” />
    </div>
    <!–/blog title –>
    </div>
    <!–/header–>
    <!–content–>
    <div id=”content”>
    <!–sidebar left –>
    <div id=”col-1″>

    <?php get_template_part(‘./template/archives’);?>

    </div>
    <!–/sidebar left –>
    <!–page –>
    <div id=”col-2″>
    <h1><?php the_title();?></h1>

    <?php

    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <p><?php the_content(‘Read more…’); ?>
    <?php endwhile; else: ?>
    <?php _e(‘Sorry, no posts matched your criteria.’); ?>
    <?php endif; ?>

    </div>
    <!–/page –>
    <?php get_template_part(‘./template/sidebar-right’);?>
    <div class=”clear”></div>
    </div>
    <!–/content–>
    <?php get_template_part(‘./template/footer’);?>
    `

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Loop.php editing for main blog page help needed’ is closed to new replies.