WordPress.org

Ready to get started?Download WordPress

Forums

Custom theme, how do i add tags/author name to end of every post (16 posts)

  1. diderkamal
    Member
    Posted 1 year ago #

    Hey guys, im new to whole wordpress world and im loving every minute of it, i've recently set up a blog using a custom theme. It does not however show tags or the name of the author who posted (i have two authors on the site both have posted more than once) i have read up on the forums about inserting codes into the index.php (or loop file) but everytime i have done so it either displays the tag/author information outside of the post itself (onto the main body of the site) or directly at the bottom of the page (not the individual posts)

    Here is the code for the index.php:

    <?php get_header(); ?>
    
    <!--Blog-->
    <div id="blog" class="clearfix">
    
      <!--Articles-->
      <div class="articles">
    
        <?php if (have_posts()) : while (have_posts()) : the_post(); $format = get_post_format(); ?>
    
          <?php if($format == ''): ?>
    
            <?php get_template_part('library/functions/theme/formats/standar'); ?>
    
          <?php else: ?> 
    
            <?php get_template_part('library/functions/theme/formats/'.$format); ?>
    
          <?php endif; ?>
    
        <?php endwhile ?> 
    
        <?php else: ?>
    
        <h2>No posts were found.</h2>
    
        <?php endif ?>
    
      <!--End .articles-->
      </div>
    
      <?php	if(page_has_nav()) :	?>
    
        <!--Navigation-->
        <div id="postnavigation" class="clearfix">
          <!--Previous-->
          <span class="prev"><?php previous_posts_link('&laquo; Previous') ?></span>
    
          <!--Next-->
          <span class="next"><?php next_posts_link('Next &raquo;','') ?></span>
    
        <!--End .navigation-->
        </div>
    
      <?php	endif;	?>  
    
     <!--Sidebar-->
     <div id="sidebar">
    
       <?php get_sidebar(); ?>
    
     <!--End .sidebar-->
     </div>
    
    <!--End #blog-->
    </div>
    
    <?php get_footer(); ?>

    and here is the code for the standar.php

    <!--Article-->
    <div <?php post_class("article standard clearfix"); ?>>
    
      <!--Date-->
      <div class="date">
        <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_date('M.j.Y'); ?></a>
      </div>
    
    	<!--Content-->
    	<div class="content clearfix">
    
    	  <!--Title-->
    	  <?php $title = get_post_meta($post->ID, 'post_header', true); if (!$title) $title = $post->post_title; ?>
    	  <h2 class="title"><a	href="<?php the_permalink() ?>"	title="<?php the_title(); ?>"><?php	echo $title;	?></a></h2>	  
    
          <?php the_content("Read the full story"); ?>
    
    	  <?php include("social.php"); ?>
    
    	<!--End .content-->
    	</div>
    
    <!--End .article-->
    </div>

    this is the page.php code

    <?php get_header(); ?>
    
    <!--Blog-->
    <div id="blog" class="clearfix">
    
      <!--Articles-->
      <div class="articles single">
    
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
          <!--Article-->
          <div <?php post_class("article standard clearfix"); ?>>
    
          	<!--Content-->
          	<div class="content clearfix">
    
          	  <!--Title-->
          	  <?php $title = get_post_meta($post->ID, 'post_header', true); if (!$title) $title = $post->post_title; ?>
          	  <h2 class="title"><a	href="<?php the_permalink() ?>"	title="<?php the_title(); ?>"><?php	echo $title;	?></a></h2>	  
    
          	  <?php the_content("Read the full story"); ?>
    
          	<!--End .content-->
          	</div>
    
          <!--End .article-->
          </div>
    
        <?php endwhile ?>
    
          <?php comments_template('', true ); ?>
    
        <?php endif ?>
    
      <!--End .articles-->
      </div>
    
    <!--End #blog-->
    </div>
    
    <?php get_footer(); ?>

    any help would be hugely apreciated! thanks

  2. ak.singla
    Member
    Posted 1 year ago #

    You should add your code above or below include('social.php'); line in standar.php

  3. diderkamal
    Member
    Posted 1 year ago #

    ok i will try that and let you know the results

  4. diderkamal
    Member
    Posted 1 year ago #

    unfortunately i have posted the code <?php the_author() ?> above social.php, below it and even next to it, to no avail? is there a different code i should be using to have author names show up?

  5. ak.singla
    Member
    Posted 1 year ago #

    Did you mistype here only -- or in the code too??

    you missed the terminator(;) in the statement.

  6. diderkamal
    Member
    Posted 1 year ago #

    i typed in <?php the_author() ?> exactly as it, where do i put the (;) ? at the end of the code?

  7. Jose Castaneda
    Member
    Posted 1 year ago #

    After the closing parentheses.

  8. ak.singla
    Member
    Posted 1 year ago #

    after the parenthesis :: <?php the_author(); ?>

  9. diderkamal
    Member
    Posted 1 year ago #

    ok i have updated the code with the correction and there is no change. I was wondering though. looking at library/fuctions/theme/formats directory, there are .php files for 'audio' 'gallery' 'image' 'quote' 'social' 'standar' and 'video'. should there be a author.php file and tag.php file present in order for them to be shown? sorry im still a little bit new to all this, still a learning curve for me

  10. ak.singla
    Member
    Posted 1 year ago #

    No -- that is not required.
    As you can fetch the post-content, and already in the Loop == you should be able to use that piece of code to get the author name.

    Can you post a link to your site?

  11. Jose Castaneda
    Member
    Posted 1 year ago #

    Template hierarchy files is what you are looking at.

  12. diderkamal
    Member
    Posted 1 year ago #

    http://theswitchscene.cu.cc/

    i wanted to add the author name and tags next to the social buttons at the bottom of my posts

  13. ak.singla
    Member
    Posted 1 year ago #

    It seems like -- the post -- above -- on the front page -- of your site are not standard post..
    Create a new post -- with some text.
    It should appear on the top, with the author name.

    For these posts, you will need all php files in your formats directory.

    These are post formats -- video, audio etc.

  14. diderkamal
    Member
    Posted 1 year ago #

    i see, i have made a new post with just text and it has posted the author name, above the social icons, instead of to the side of it. but when i create a post with media on it, it does not post the author name?

  15. ak.singla
    Member
    Posted 1 year ago #

    For those posts, you will need to edit all php files in your formats directory.

  16. diderkamal
    Member
    Posted 1 year ago #

    Ok i understand now, and is there a way i can place the author name directly to the side of the social sharing buttons instead of directly above them? like a certain div code or somthing?

Topic Closed

This topic has been closed to new replies.

About this Topic