Andrew on "How to format PHP IF...ELSE conditional statement?"

ساخت وبلاگ

jrcollins
Member
Posted 10 minutes ago #

I'm using the following PHP conditional statement to display featured images:

<?php if(is_category('blog-posts')) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-thumb' ); }
else {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); }
?>

The code works as is, but don't I need to include <?php endif; ?>?

There doesn't always have to be an endif, that's just an alteative way of formatting your conditional statements; http://php.net/manual/en/control-structures.alteative-syntax.php

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 84 تاريخ : پنجشنبه 27 اسفند 1394 ساعت: 5:41