Help with PHP (if, elseif, else) Statements
-
G’day,
I would greatly appreciate some assistance with (2) separate php statements.
I have uploaded gd-star-ratings and need to display different multi-rating blocks based on the category a post is located in.
Note: These rating blocks are being integrated into the comments section via comments.php and template_functions.php (Hybrido Theme)
=====================================
COMMENTS.PHP
ORIGINAL STATEMENT (Works)
<?php if (defined("STARRATING_INSTALLED")) : ?> <label for="url"><small>Rating</small></label> <p><?php wp_gdsr_comment_integrate_multi_rating(2); ?> </p><?php endif; ?>NEW STATEMENTS
<?php if (in_category('9') && defined("STARRATING_INSTALLED")) : ?> <label for="url"><small>Rating</small></label> <p><?php wp_gdsr_comment_integrate_multi_rating(2); ?> </p><?php endif; ?><?php if (in_category('18') && defined("STARRATING_INSTALLED")) : ?> <label for="url"><small>Rating</small></label> <p><?php wp_gdsr_comment_integrate_multi_rating(3); ?> </p><?php endif; ?><?php if (in_category('20') && defined("STARRATING_INSTALLED")) : ?> <label for="url"><small>Rating</small></label> <p><?php wp_gdsr_comment_integrate_multi_rating(4); ?> </p><?php endif; ?>Not sure if it’s okay to do this way WITHOUT using (if, elseif, else) but it seems to be working with each category showing it’s respective rating block.
=====================================
TEMPLATE_FUNCTIONS.PHP
ORIGINAL STATEMENT (Works)
<?php if (defined("STARRATING_INSTALLED")) : ?> <div style="float: right"> <?php wp_gdsr_comment_integrate_multi_result(get_comment_ID(), 2, 51, "crystal", 16); ?> </div> <?php endif; comment_text(); ?> <div><?php wp_gdsr_render_comment_thumbs(26); ?></div>NOTE: (2) represents the multi rating block ID
NEW STATEMENTS
<?php if (in_category('9') && defined("STARRATING_INSTALLED")) : ?> <div style="float: right"> <?php wp_gdsr_comment_integrate_multi_result(get_comment_ID(), 2, 51, "crystal", 16); ?> </div> <?php endif; comment_text(); ?> <div><?php wp_gdsr_render_comment_thumbs(26); ?></div><?php if (in_category('18') && defined("STARRATING_INSTALLED")) : ?> <div style="float: right"> <?php wp_gdsr_comment_integrate_multi_result(get_comment_ID(), 3, 51, "crystal", 16); ?> </div> <?php endif; comment_text(); ?> <div><?php wp_gdsr_render_comment_thumbs(28); ?></div><?php if (in_category('20') && defined("STARRATING_INSTALLED")) : ?> <div style="float: right"> <?php wp_gdsr_comment_integrate_multi_result(get_comment_ID(), 5, 51, "crystal", 16); ?> </div> <?php endif; comment_text(); ?> <div><?php wp_gdsr_render_comment_thumbs(30); ?></div>The above format does display correct blocks in comments based on category, BUT the (comment text) and (thumbs block – ID 26) are being shown three times for each comment.
I have spent a few days trying different (if, elseif, else) statements, but I just can’t seem to get it right.
If someone has the time to help with these statememts, it would be greatly appreciated.
Thanks.
The topic ‘Help with PHP (if, elseif, else) Statements’ is closed to new replies.