WordPress.org

Ready to get started?Download WordPress

Forums

Trouble with conditional category tags in index page (6 posts)

  1. brittanie
    Member
    Posted 5 years ago #

    I'm trying to create a tumblelog based on these instructions at Openswitch and I can't even get past the first bit of code. I am using a slightly modified version of the Tiny theme, which I'd like to modify further into a tumblelog format.

    My index looks like this:

    <?php
    // index.php
    // Tiny theme for WordPress
    // Copyright (C) 2005 Ben de Groot
    // Distributed under the terms of the GNU General Public License v2
    
    get_header();
    // Check if the sitemap is requested
    if ( isset($_GET['sitemap']) ) {
    	include('sitemap.php');
    
    } else {
    
    if (have_posts()) : while (have_posts()) : the_post();
    
    ?>
    
    <h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e('Permanent Link','bnTiny'); ?>: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
    <p class="posted"><?php the_date('', '', ' at', TRUE); ?> <?php the_time(); ?> | <?php the_category(', '); ?> | <?php comments_popup_link( __('No Comments','bnTiny'), __('1 Comment','bnTiny'), __('% Comments','bnTiny') ); ?>
    
    <?php edit_post_link($link = __('Edit','bnTiny'), $before = ' | ', $after = ''); ?></p>
    
    <?php the_content(); ?><br />
    
    <?php endwhile; ?>
    
    <p class="nav"><span class="prev"><?php posts_nav_link( '', '', __('« Previous Entries','bnTiny') ) ?></span>
    
    <span class="next"><?php posts_nav_link( '', __('Next Entries »','bnTiny'), '' ) ?></span></p>	
    
    <?php else: ?>
    
    <p><?php _e('Sorry, nothing found.','bnTiny'); ?></p>
    
    <?php endif; ?>
    
    <?php
    
    }
    
    get_footer(); ?>

    I am trying to paste the first conditional code:

    <?php if ( in_category(4) && !is_single() ) : ?>
    
    <div class=“post”>
    
    <span class=“permalink”> <a href=”<?php the_permalink() ?>” rel=“bookmark” title=“Permanent Link to <?php the_title(); ?>”>¶</a></span>
    
    <div class=“post_body”>
    
    <div class=“conversation”>
    
    <?php the_content(); ?>
    
    </div>
    
    </div>
    
    </div>

    in there somewhere but no matter where I put it I come up with a syntax error. I don't know a whole lot about PHP but I thought I knew more than this. Help please!

  2. frotzed
    Member
    Posted 5 years ago #

    The easiest way to create your own tumblelog with WordPress is to use Sandbox. But there are other, pre-packaged, tumblelog themes out there that are super easy to use.

  3. brittanie
    Member
    Posted 5 years ago #

    I prefer to tweak the theme I am already using.

  4. Justin Tadlock
    Member
    Posted 5 years ago #

    What kind of syntax error? Post the error here.

    From what I can see, you have those WordPress "curly" quotes or whatever in that second bit of code. See:

    <div class=“post”>

    See those slanted quote marks? That might be your problem.

  5. brittanie
    Member
    Posted 5 years ago #

    Here is the error:

    Parse error: syntax error, unexpected T_ENDWHILE in /home/rulebrit/public_html/wp-content/themes/tiny/index.php on line 67

    and this is what my code looks like:

    <?php
    
    // index.php
    
    // Tiny theme for WordPress
    
    // Copyright (C) 2005 Ben de Groot
    
    // Distributed under the terms of the GNU General Public License v2
    
    get_header();
    
    // Check if the sitemap is requested
    
    if ( isset($_GET['sitemap']) ) {
    
    	include('sitemap.php');
    
    } else {
    
    if (have_posts()) : while (have_posts()) : the_post();
    
    ?>
    
    <!— conversation —>
    
    <?php if ( in_category(4) && !is_single() ) : ?>
    
    <div class="post">
    
    <span class="permalink"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">¶</a></span>
    
    <div class="post_body">
    
    <div class="conversation">
    
    <?php the_content(); ?>
    
    </div>
    
    </div>
    
    </div>
    
    	<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e('Permanent Link','bnTiny'); ?>: <?php the_title(); ?>"><?php
    
        the_title(); ?></a></h2>
    
    	<p class="posted"><?php the_time('j F Y'); ?> | <?php the_category(', '); ?> | <?php comments_popup_link( __('No Comments','bnTiny'), __('1 Comment','bnTiny'), __('% Comments','bnTiny') ); ?>
    
    	<?php edit_post_link($link = __('Edit','bnTiny'), $before = ' | ', $after = ''); ?></p>
    
    	<?php the_content(); ?>
    
    <?php endwhile; ?>
    
    	<p class="nav"><span class="prev"><?php posts_nav_link( '', '', __('« Previous Entries','bnTiny') ) ?></span>
    
    	<span class="next"><?php posts_nav_link( '', __('Next Entries »','bnTiny'), '' ) ?></span></p>
    
    <?php else: ?>
    
    	<p><?php _e('Sorry, nothing found.','bnTiny'); ?></p>
    
    <?php endif; ?>
    
    <?php
    
    }
    
    get_footer(); ?>

    Basically I am just trying to post that second snippet right inside The Loop, but no matter where I post it I get a syntax error.

  6. Justin Tadlock
    Member
    Posted 5 years ago #

    Quickly looking at this (I'll stop back by tonight when I can look at it better), it looks like you need another:

    <?php endif; ?>

    before your endwhile.

Topic Closed

This topic has been closed to new replies.

About this Topic