php - How to add title and date only to blog posts on word press -
i new wordpress , trying display title , post date on blog posts only. couldn't find answers when googling , binging. no matter page displaying title page , date made on.
here index code using:
<?php get_header(); ?> <div id="main"><br><br> <div id="content"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1><?php the_title(); ?></h1> <p><?php the_content(__('(more...)')); ?></p> <h4>posted on <?php the_time('f js, y') ?></h4> <br> <?php endwhile; else: ?> <p><?php _e('sorry, no posts matched criteria.'); ?></p><?php endif; ?> </div> <?php get_sidebar(); ?> </div> <div id="delimiter"> </div> <?php get_footer(); ?>
i know calling title on every page , phrase "posted on". know how display on blog posts.
thank in advance.
a better approach edit template files related respective pages.
in current code, can check post type of current post within loop. display title , date conditionally.
<?php get_header(); ?> <div id="main"><br><br> <div id="content"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $posttype = get_post_type(); if($posttype == 'post'){ ?> <h1><?php the_title(); ?></h1> <?php } ?> <p><?php the_content(__('(more...)')); ?></p> <?php if($posttype == 'post'){ ?> <h4>posted on <?php the_time('f js, y') ?></h4> <?php } ?> <br> <?php endwhile; else: ?> <p><?php _e('sorry, no posts matched criteria.'); ?></p><?php endif; ?> </div> <?php get_sidebar(); ?> </div> <div id="delimiter"> </div> <?php get_footer(); ?>
Comments
Post a Comment