• Ok, I would like to allow visitors to suggest tags for my posts. I have found this plugin which purports to do just that:

    http://wordpress.org/extend/plugins/community-tags/installation/

    As you can see from this install page, the directions are simple and to the point. Only problem is I don’t know a thing about the post loop.

    I was able to find a little bit more information about adding items to the loop:

    http://codex.wordpress.org/The_Loop

    However, I have not been able to find a single index.php file which contains the lines which the above link claim begin and end the post loop.

    I am using the default theme and I would like to know where the single line of code for the above mentioned plugin should be placed. If I have to create my own post loop somewhere, I’m going to need more assistance.

Viewing 15 replies - 1 through 15 (of 30 total)
  • wp-content/themes/YOURTHEME/index.php
    or
    wp-content/themes/default/index.php

    And a few other files also use the loop…

    Thread Starter jamesisin

    (@jamesisin)

    Um, yeah, got that. The page called The_Loop which I link to above claims that, for instance, the loop begins with:

    <?php if ( have_posts()

    And my index.php file, which is located in themes/deafult, does not contain that associated line of code. You see the problem? I can’t find the loop.

    The default theme most certainly does..

    index.php
    archive.php
    single.php

    The list goes on, the loop code most definately is in those files.

    Thread Starter jamesisin

    (@jamesisin)

    Odd, I can see the opening line. Not sure why it didn’t show up when I did a find in page (in WordPad). We’ll blame that one on MS.

    Ok, so now I see the Loop in my index.php file. Where, within that loop, do I place the code? Does its placement matter? At the end?

    Anywhere between..

    <?php while (have_posts()) : the_post(); ?>

    and

    <?php endwhile; ?>

    Thread Starter jamesisin

    (@jamesisin)

    Well, I added the requisite line of code immediately before the <?php endwhile; ?> statement and that caused all kinds of havoc. My blog stopped loading or loaded blank. I have commented that line out but my main blog page still fails to respond (times out), though all sub-pages seem to be responding.

    A little help?

    http://SoundUnReason.com/InkWell (this won’t work, likely)

    http://www.soundunreason.com/InkWell/?page_id=321 (any of the sub-InkWell links seem to be working)

    Thread Starter jamesisin

    (@jamesisin)

    I am greatly confused. I don’t seem to be able to functionally comment out lines of code (or comments) in that file. I have tried prepending each line to ignore with // and # and I have tried enclosing the text/code to be ignored with /* */ and in all three cases this code hoses my main page. I have to remove that line (though not my comment line) in order for my site to function. What’s up with that?

    Whatever file you’re editing…

    Post the code from that file here please inside backticks

    `

    I assume you’ve uploaded the plugin files and activated the plugin via admin, as the instructions say..

    Thread Starter jamesisin

    (@jamesisin)

    It’s the default theme’s index.php file. We all have one. But here you go:

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    				<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    			</div>
    
    #  Line of code added from:     wordpress.org/extend/plugins/community-tags/installation/
    
    #  <?php $post_id = the_ID(); <div id="tagthis-$post_id" class="tagthis" style="display:none"></div> ?>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    You can see the two lines I’m working with (prepended by #) about in the middle. I don’t have that second line present in the live version because it hoses my site; I’m including it here so you can see it in the version with both lines commented out and still hosing things.

    Thread Starter jamesisin

    (@jamesisin)

    And, sorry, yes, the plug in is loaded and activated.

    Thread Starter jamesisin

    (@jamesisin)

    You know, I’m wondering if this is in fact the best location for this line of code anyway. I’ll explain.

    It seems that this particular file effects the main page which lists all the posts in a long list (broken into pages of 15 posts I think). It would make more sense to put this tag adding code on the individual posts (with the comment boxes, say). Should I work on adding this code to a different file which would do that instead of adding to this one? Does that make sense?

    Think i see the issue…. the plugin instructions say to add this…

    <?php $post_id = the_ID(); <div id="tagthis-$post_id" class="tagthis" style="display:none"></div> ?>

    This code is just incorrect and non-funcitonal… the HTML and PHP is incorrectly nested..

    This however should work…
    <div id="tagthis-<?php the_ID();?>" class="tagthis" style="display:none"></div>

    And yes you’re also right about the file, place the above code into single.php and you’ll see the input form for submitting tags…..

    admin.php?page=ct-manage-tags

    To manage the tags… or bottom-left menu item..

    Also caused a PHP on the first tag, seems to have disappeared now i have made a few tags…

    Also you may wish to change these lines in… category-tags-add.php

    // wp_redirect(get_permalink($post_id) );
    echo $post_id.',success';

    to

    wp_redirect(get_permalink($post_id) );
    // echo $post_id.',success';

    So when a tag has been added it re-directs back to the post..

    Thread Starter jamesisin

    (@jamesisin)

    Ok, I think we are getting very close. I made the redirect change–I think that was a good idea.

    I know the code I entered into single.php is effecting the correct page(s) on my site, because initially I was using php comments and not html comments so my comment line appeared (on the bottom of individual posts). However, I am not getting any a tag-adding fields or such similar. Here is my single.php:

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    get_header();
    ?>
    
    	<div id="content" class="widecolumn">
    
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div>
    			<div class="alignright"><?php next_post_link('%link &raquo;') ?></div>
    		</div>
    
    		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    			<h2><?php the_title(); ?></h2>
    
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    				<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
    
    				<p class="postmetadata alt">
    					<small>
    						This entry was posted
    						<?php /* This is commented, because it requires a little adjusting sometimes.
    							You'll need to download this plugin, and follow the instructions:
    							http://binarybonsai.com/archives/2004/08/17/time-since-plugin/ */
    							/* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?>
    						on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?>
    						and is filed under <?php the_category(', ') ?>.
    						You can follow any responses to this entry through the <?php post_comments_feed_link('RSS 2.0'); ?> feed.
    
    						<?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
    							// Both Comments and Pings are open ?>
    							You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(); ?>" rel="trackback">trackback</a> from your own site.
    
    						<?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
    							// Only Pings are Open ?>
    							Responses are currently closed, but you can <a href="<?php trackback_url(); ?> " rel="trackback">trackback</a> from your own site.
    
    						<?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
    							// Comments are open, Pings are not ?>
    							You can skip to the end and leave a response. Pinging is currently not allowed.
    
    						<?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
    							// Neither Comments, nor Pings are open ?>
    							Both comments and pings are currently closed.
    
    						<?php } edit_post_link('Edit this entry','','.'); ?>
    
    					</small>
    				</p>
    
    			</div>
    		</div>
    
    <!--  User-tagging code from: http://wordpress.org/support/topic/255106  -->
    
    <div id="tagthis-<?php the_ID();?>" class="tagthis" style="display:none"></div>
    
    	<?php comments_template(); ?>
    
    	<?php endwhile; else: ?>
    
    		<p>Sorry, no posts matched your criteria.</p>
    
    <?php endif; ?>
    
    	</div>
    
    <?php get_footer(); ?>

    I am placing it incorrectly? Thoughts?

Viewing 15 replies - 1 through 15 (of 30 total)
  • The topic ‘The Loop and my default theme’ is closed to new replies.