Forums

Post_Class Category...imputing complete different styles in index (7 posts)

  1. TotallyLost
    Member
    Posted 1 year ago #

    I am developing a personal theme that has a different post style for 3 different categories. Inspired by Tumblrs different images per category.

    I understand that post_class can help you achieve this but I am asking for a completely different style post (including alignment within the image box).. versus just a header color change.

    Here is a mark-up through html of what I want to achieve...(The post at the bottom if category specific) Mark-Up

    As noted: (for the rest of my content post is have this)

    <div id="content">
      <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
       <div id="post" <?php the_ID(); ?>>
        <div class="posttop"></div>
        <div id="postmiddle">
          <div class="posttitle"><a href="<?php the_permalink();?>"><?php the_title(); ?></a></div>
          <div id="info"><small>Born On:</small> <?php the_date('F jS, Y'); ?></div>
          <div id="info2"><small>Subject:</small> <?php the_category(', '); ?></div>
          <?php the_content('Read More???'); ?>
        </div>
        <div class="postbottom"> Comments (<?php comments_popup_link('0', '1', '%', '', __('Off')); ?>) * Like (48)</div>
       </div>

    But I want this code to be added for if(category-sounds):

    <div id="musicsheet">
          <div class="posttitle"><a href="<?php the_permalink();?>"><?php the_title(); ?></a></div>
         <div id="infocenter">
          <div id="info3">Born On: <?php the_date('F jS, Y'); ?></div>
         </div>
    <?php the_content(); ?>
          <div class="like">Like (27)</div>
       </div>

    Now in post_class: it states in css style for ".category_sounds" to implement the image and size and such.... but what about the positioning inside? How would it be able to call those even if I did have ".category_sounds .info3", how can it pick it up without html?

    And how would that convert to functions.php?

    I dont see anybody doing this in WordPress..

    I really would like to know how this would be executed? Thank You

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    I am asking for a completely different style post ... versus just a header color change.

    this is not wordpress, but have a look at:
    http://www.csszengarden.com/
    about the possibilities of css

  3. TotallyLost
    Member
    Posted 1 year ago #

    I have no problem with the possiblities of CSS... I can do that all day.. and HTML... My problem is implementing these different styles within the PHP loop for wordpress.

  4. alchymyth
    The Sweeper
    Posted 1 year ago #

    But I want this code to be added for if(category-sounds):

    for instance:

    <?php if( in_category('sounds') ) { ?>
    <!--/*THIS CODE HERE*/-->
    <?php } ?>

    http://codex.wordpress.org/Conditional_Tags
    http://codex.wordpress.org/Conditional_Tags#A_Category_Page

  5. TotallyLost
    Member
    Posted 1 year ago #

    Im just going to latch on to you for a sec. :)

    This is after:

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

    right?

    cause I tried this and it was giving me a syntax error.

    BTW Thank you for dealing with me.

  6. alchymyth
    The Sweeper
    Posted 1 year ago #

    yes, this is in the loop.

    syntax errors (the error mesage would helpful) often come from ignoring the right sequence of opening and closing php tags.

  7. TotallyLost
    Member
    Posted 1 year ago #

    Hi Alchymyth,
    THE CATEGORY CHANGES HAVE WORKED!!! I now have 3 different templates between 5 categories!

    But now I have run into a new problem... just about anything listed after <?php }?> does not list... I had to put both sidebars above the code to see it (which isnt a problem)... I listed the code underneath from my index.php

    Can you please have a look and tell me what Im doing wrong so that I can correct it and have my navigation and footer pop up??? I did alternate the coding around a lot after reading the Conditional tags but it doesnt work.

    <?php get_header(); ?>
    
    <?php get_sidebar(); ?>
    
    <div id="rightsidebar"></div>
    
     <div id="content">
    
      <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
    
        <?php if( in_category('sounds') ) { ?>
        <div id="musicsheet" <?php the_ID(); ?>>
          <div class="posttitle"><a href="<?php the_permalink();?>"><?php the_title(); ?></a></div>
         <div class="infocenter">
          <div class="info3">Born On: <?php the_date('F jS, Y'); ?></div>
          <div class="center"><?php the_content(); ?></div>
         </div>
          <div class="like"><?php if(function_exists('wp_likes_render_post')) wp_likes_render_post();?></div>
        </div>
    
        <?php } elseif(in_category('random-moments') ) { ?>
        <div id="notebook" <?php the_ID(); ?>>
        <div class="notebookt"><div class="posttitle"><a href="<?php the_permalink();?>"><?php the_title(); ?></div>
        <div class="info5"><small>Born On:</small> <?php the_date('F jS, Y'); ?> <small>Subject:</small> <?php the_category(', '); ?></div>
        </div>
        <div class="notebookm">
        <div class="write">
        <?php the_content(''); ?></div>
        </div>
        <div class="notebookb"><?php comments_popup_link('Comment', 'Comment (1)', 'Comments (%)', '', __('Off')); ?> * <?php if(function_exists('wp_likes_render_post')) wp_likes_render_post();?></div>
        </div>
    
        <?php } elseif(in_category('random-thoughts') ) { ?>
        <div id="notebook" <?php the_ID(); ?>>
        <div class="notebookt"><div class="posttitle"><a href="<?php the_permalink();?>"><?php the_title(); ?></div>
        <div class="info5"><small>Born On:</small> <?php the_date('F jS, Y'); ?> <small>Subject:</small> <?php the_category(', '); ?></div>
        </div>
        <div class="notebookm">
        <div class="write">
        <?php the_content(''); ?></div>
        </div>
        <div class="notebookb"><?php comments_popup_link('Comment', 'Comment (1)', 'Comments (%)', '', __('Off')); ?> * <?php if(function_exists('wp_likes_render_post')) wp_likes_render_post();?></div>
        </div>
    
        <?php } elseif(in_category('ksywbc') ) { ?>
        <div id="notebook" <?php the_ID(); ?>>
        <div class="notebookt"><div class="posttitle"><a href="<?php the_permalink();?>"><?php the_title(); ?></div>
        <div class="info5"><small>Born On:</small> <?php the_date('F jS, Y'); ?> <small>Subject:</small> <?php the_category(', '); ?></div>
        </div>
        <div class="notebookm">
        <div class="write">
        <?php the_content(''); ?></div>
        </div>
        <div class="notebookb"><?php comments_popup_link('Comment', 'Comment (1)', 'Comments (%)', '', __('Off')); ?> * <?php if(function_exists('wp_likes_render_post')) wp_likes_render_post();?></div>
        </div>
    
    	<?php } else { ?>
        <div id="post" <?php the_ID(); ?>>
        <div class="posttop"></div>
        <div class="postmiddle">
          <div class="posttitle"><a href="<?php the_permalink();?>"><?php the_title(); ?></a></div>
          <div class="info"><small>Born On:</small> <?php the_date('F jS, Y'); ?></div>
          <div class="info2"><small>Subject:</small> <?php the_category(', '); ?></div>
          <?php the_content('Read More???'); ?>
         </div>
        <div class="postbottom"><?php comments_popup_link('Comment', 'Comment (1)', 'Comments (%)', '', __('Off')); ?> * <?php if(function_exists('wp_likes_render_post')) wp_likes_render_post();?></div>
       </div>
    
       <?php } ?>
    
        <?php endwhile ?>
       <div id="navigation">
        <div class="alignleft"></div>
        <div class="aligncenter"><?php if (function_exists("kira_pagination")) {
        pagination($additional_loop->max_num_pages);
    } ?></div>
        <div class="alignright"></div>
        </div>
    
        <?php endif ?>
     </div>
    
     <?php get_footer(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic