Query Post as a Bulleted list
-
I created a new page template to feed 1 of my blog categories to another page within my blog. My question is: Can I make the new page of blog entries appear as a bulleted list instead of looking like a bunch of posts? The new page is RTW you Say…..
https://www.thebigfatworld.com
thanks
Megan
-
Here’s some code I use:
<ul> <li><strong><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><span><?php the_title(); ?></span></a></strong><br /> @ <?php the_time('m/d/Y'); ?> by <?php the_author_posts_link(); ?><br /> <?php comments_popup_link('Comments (0)', 'Comment (1)', 'Comments (%)'); ?></li> </ul>
This will show a title link, the author, and the number of comments, in a bulleted unordered list. You would use this in your loop.
Notice I left out
the_content
, so this is merely a list of titles showing none of the post content until a user clicks on the post.Worked great but what snippet of code must I remove to only show the bulleted list? See below:
<?php
/*
Template Name: RTW
*/
?><?php get_header(); ?>
<?php
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$args= array(
‘category_name’ => ‘RTW’,
‘paged’ => $paged
);
query_posts($args);
?><?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class=”post” id=”post-<?php the_ID(); ?>”>
<?php if ($freshy_options[‘author’]) : ?><small class=”author”><?php the_author(); ?></small><?php endif; ?>
<?php if ($freshy_options[‘date’]) : ?>
<small class=”date”><?php if ($freshy_options[‘author’]) : ?>|<?php endif; ?> <?php the_time(get_option(‘date_format’)) ?></small>
<?php endif; ?>
<?php if ($freshy_options[‘time’]) : ?>
<small class=”date”><?php if ($freshy_options[‘date’]) : ?>|<?php endif; ?> <?php the_time() ?></small>
<?php endif; ?><div class=”entry”>
<?php the_content(‘<span class=”readmore”>’.__(‘Read the rest of this entry »’,TEMPLATE_DOMAIN).'</span>’); ?></div>
<div class=”meta”>
<dl>
<dt><?php _e(‘Comments’,TEMPLATE_DOMAIN); ?></dt><dd><?php comments_popup_link(__(‘No Comments »’,TEMPLATE_DOMAIN), __(‘1 Comment »’,TEMPLATE_DOMAIN), __(‘% Comments »’,TEMPLATE_DOMAIN)); ?></dd>
<dt>
<?php _e(‘Categories’,TEMPLATE_DOMAIN); ?></dt><dd><?php the_category(‘, ‘) ?></dd>
<?php if(function_exists(‘the_tags’)) : ?>
<?php the_tags(‘<dt>Tags</dt><dd>’, ‘, ‘, ‘</dd>’); ?>
<?php endif; ?>
<?php if(function_exists(‘the_bunny_tags’)) : ?>
<?php the_bunny_tags(‘<dt>Tags</dt><dd>’, ‘</dd>’, ‘, ‘); ?>
<?php endif; ?>
<?php if(function_exists(‘the_bookmark_links’)) : ?>
<dt><?php _e(‘Spread the word’,TEMPLATE_DOMAIN); ?></dt><dd><?php the_bookmark_links(); ?></dd>
<?php endif; ?>
<?php if (‘open’ == $post-> comment_status) : ?>
<dt><img alt=”<?php _e(‘Comments rss’,TEMPLATE_DOMAIN); ?>” src=”<?php echo get_bloginfo(‘stylesheet_directory’) ?>/images/icons/feed-icon-16×16.gif” /> <?php comments_rss_link(__(‘Comments rss’,TEMPLATE_DOMAIN)); ?></dt>
<?php endif; ?>
<?php if (‘open’ == $post->ping_status) : ?>
<dt><img alt=”<?php _e(‘Trackback’,TEMPLATE_DOMAIN); ?>” src=”<?php echo get_bloginfo(‘stylesheet_directory’) ?>/images/icons/trackback-icon-16×16.gif” /> ” rel=”trackback” title=”<?php _e(‘Trackback’,TEMPLATE_DOMAIN); ?>”><?php _e(‘Trackback’,TEMPLATE_DOMAIN); ?></dt>
<?php endif; ?>
<?php if ($user_ID) : ?>
<dt><img alt=”<?php _e(‘Edit’,TEMPLATE_DOMAIN); ?>” src=”<?php echo get_bloginfo(‘stylesheet_directory’) ?>/images/icons/edit-icon-16×16.gif” /> <?php edit_post_link(__(‘Edit’,TEMPLATE_DOMAIN),”,”); ?></dt>
<?php endif; ?>
</dl>
</div></div>
<?php endwhile; ?>
<p class=”navigation”>
<span class=”alignleft”><?php next_posts_link(__(‘« Previous Entries’,TEMPLATE_DOMAIN)) ?></span>
<span class=”alignright”><?php previous_posts_link(__(‘Next Entries »’,TEMPLATE_DOMAIN)) ?></span>
</p><?php else : // nothing found ?>
<div class=”post” id=”post-none”>
<h2><?php _e(‘Not found’,TEMPLATE_DOMAIN); ?></h2>
<p><?php _e(“Sorry, but you are looking for something that is not here”,TEMPLATE_DOMAIN); ?></p>
</div>
<?php endif; ?></div>
<?php // sidebars ?>
<?php if ($freshy_options[‘sidebar_right’] == true) get_sidebar(); ?>
<?php if ($freshy_options[‘sidebar_left’] == true) include (TEMPLATEPATH . ‘/sidebar_left.php’); ?></div>
<?php get_footer(); ?>
Try everything after:
<div class="post" id="post-<?php the_ID(); ?>">
All the way to just before:
<?php endwhile; ?>
Then insert the code I gave you. If you’re still having trouble, it’ll be easier if you paste your code at wordpress.pastebin.ca and report the link back here.
I played around and go it to work but had a bad side effect, the side bars are now centered on my site, directly under the bulleted list. New code looks like this : https://wordpress.pastebin.ca/1442483
thanks for all your help
Looks like you’re missing closing
</li>, </ul>, </div>
. Starting at the opening<ul>
it should look like:<ul> <li><strong><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><span><?php the_title(); ?></span></a></strong><br /> </li> </ul> </div>
Try that.
I think your
<div>
s may be the issue. Trying to play around with it.The post content area (currently #frame) ideally needs to have its own unique id (eg. #frame2) that can then be styled without impacting on any other pages.
So in header.php, maybe try:
<div class="container"> <?php if(is_category('rtw-you-say-whats-next') :?><div id="frame2"> <?php else :?> <div id="frame"><?php endif;?>
Then something like:
.sidebar_left #frame2 { float:right; padding-left:270px; }
in custom_my_style.css should sort it out. In theory…
- The topic ‘Query Post as a Bulleted list’ is closed to new replies.