简体   繁体   中英

Modifying PHP and HTML with IF statement for Wordpress

I am trying to modify this Wordpress theme: http://www.elegantthemes.com/preview/DailyNotes/

For a regular Text Post, I want it to display a thumbnail picture if one exists. Otherwise, just display the Title and Excerpt from the post. Here is the IF and ELSE statement that I am stuck on. I can't get it to work and it's one or the other (always IF or always ELSE) when I change the conditional statement.

<?php if ($arr[$j]['posttype'] == 'text') { ?>
  <div class="inside" onclick="window.location='<?php echo $arr[$j]["permalink"];?>'">
    <?php if (file_exists($arr[$j]["thumb"])) { ?>
      <span class="photospan">    
        <img src="<?php bloginfo('template_directory'); ?>/images/shadow-overlay.png" alt="thumbnail" class="thumb_overlay" />
        <?php print_thumbnail($arr[$j]["thumb"], $arr[$j]["use_timthumb"], $arr[$j]['title'] , 149, 149, '', $post = $arr[$j]["post"]); ?>
      </span>
    <?php } else { ?>
      <div class="overflow">
        <h2><?php echo($arr[$j]['title']); ?></h2>
        <?php echo $arr[$j]['excerpt']); ?>
      </div>
    <?php } ?>
    <img class="icon" src="<?php bloginfo('template_directory'); ?>/images/icon-photo.gif" alt="article post" />
  </div>
<?php }; ?>         

I tried putting in different arguments of the print_thumbnail function into the IF statement and it doesn't work. Here are the arguments for the print_thumbnail function in case it helps:

function print_thumbnail($thumbnail = '', $use_timthumb = true, $alttext = '', $width = 100, $height = 100, $class = '', $echoout = true, $forstyle = false, $resize = true, $post='') {

Can anyone tell me which argument I should use in my IF statement? Thanks in advance and let me know if you need more information.

You need to do <?php if ($arr[$j]["thumb"]) { ?>

and then

else if (!$arr[$j]["thumb"]) {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM