I've created a page through WP admin and I want page to only display what I put in the content area. I'm pretty sure I should use something like this - <?php the_content(); ?> - but I'm not sure of the specifics.
If I use the Loop from index.php (starkers) the content of the page displays but the "page name," "posted on, "author," "comments," etc are all included. I just want the content from page without the other stuff.
I've tried this:
<?php query_posts(); the_post(); ?>
<?php the_content(); ?>
<?php wp_reset_query(); ?>
It seems to work, but I'm not sure if it's the "correct" way to do it. I don't want to use something sloppy if there's a better way.
The loop in the starkers blank theme I'm using is in a file called loop.php (see below). I understand the basics of how the loop works but I'm not sure what the bare minimum I need to use to show only the content on a single page...
Is there is a "simpler" version I can use on just one page?
<?php /** * The loop that displays posts. * * The loop displays the posts and the post content. See * http://codex.wordpress.org/The_Loop to understand it and * http://codex.wordpress.org/Template_Tags to understand * the tags used in it. * * This can be overridden in child themes with loop.php or * loop-template.php, where 'template' is the loop context * requested by a template. For example, loop-index.php would * be used if it exists and we ask for the loop with: * <code>get_template_part( 'loop', 'index' ); * * @package WordPress * @subpackage Starkers * @since Starkers 3.0 */ ?>
<?php /* If there are no posts to display, such as an empty archive page */ ?> <?php if ( ! have_posts() ) : ?> <?php _e( 'Not Found', 'twentyten' ); ?> <?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?> <?php get_search_form(); ?>
<?php endif; ?>
<?php<br /> /* Start the Loop. * * In Twenty Ten we use the same loop in multiple contexts. * It is broken into three main parts: when we're displaying * posts that are in the gallery category, when we're displaying * posts in the asides category, and finally all other posts. * * Additionally, we sometimes check for whether we are on an * archive page, a search page, etc., allowing for small differences * in the loop on each template without actually duplicating * the rest of the loop that is shared. * * Without further ado, the loop: */ ?> <?php while ( have_posts() ) : the_post(); ?>
<?php /* How to display posts in the Gallery category. */ ?>
Yeah, man. Starker's loop.php is frigging insane. That was not what I expected at all after following Chris's WP theme video tutorial.
One thing I realized, though, is when Chris deleted a lot of Starker's extra stuff, he deleted some things that might be pretty important to you... for example, the very first thing I wanted to do couldn't be done because Chris had removed the Featured Image functionality on his Personal Homepage Theme. I had to look around for a few hours to find out how to fix that.
BTW, in case you're wondering, this is how you fix it... add these two lines to the top of your functions.php file under the opening <?php tag:<br /> add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 80, 55, true ); // W x H, hard crop if you want the thumbnails to automatically crop... adjust the size or just comment this line out if you want to adjust them with CSS.
Starkers is a great tool because it has everything you would need for a basic wordpress site to function on. You just need to read up on the wordpress codex some more to understand what certain functions are doing. I would suggest using this for a generic page grab in your theme.
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?>
The query posts allows you to alter it so that you can find a certain post or posts that have the selections you want like tags, custom fields, dates etc.
If I use the Loop from index.php (starkers) the content of the page displays but the "page name," "posted on, "author," "comments," etc are all included. I just want the content from page without the other stuff.
I've tried this:
It seems to work, but I'm not sure if it's the "correct" way to do it. I don't want to use something sloppy if there's a better way.
Thank you,
Charlie
Al
Is there is a "simpler" version I can use on just one page?
OR THIS...
I tested both and they seem to work the same. Are there any advantages to one over the other?
One thing I realized, though, is when Chris deleted a lot of Starker's extra stuff, he deleted some things that might be pretty important to you... for example, the very first thing I wanted to do couldn't be done because Chris had removed the Featured Image functionality on his Personal Homepage Theme. I had to look around for a few hours to find out how to fix that.
BTW, in case you're wondering, this is how you fix it... add these two lines to the top of your functions.php file under the opening <?php tag:<br />
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 80, 55, true ); // W x H, hard crop if you want the thumbnails to automatically crop... adjust the size or just comment this line out if you want to adjust them with CSS.
The query posts allows you to alter it so that you can find a certain post or posts that have the selections you want like tags, custom fields, dates etc.