I’m trying to output different text depending on the custom post type and I’m getting a syntax error which I believe is due to multiple if-statements. The problem is that I have a very limited knowledge of PHP. Any ideas?
<?php
if ( 'lettering' == get_post_type() ) {
<?php if( function_exists( 'attachments_get_attachments' ) ) {
$attachments = attachments_get_attachments();
$total_attachments = count( $attachments );
if( $total_attachments ) : ?>
<ul id="process"><span>Process:</span>
</ul>
<br>
<?php endif; ?> <?php } ?>
} elseif ( 'type' == get_post_type() ) {
<?php if( function_exists( 'attachments_get_attachments' ) ) {
$attachments = attachments_get_attachments();
$total_attachments = count( $attachments );
if( $total_attachments ) : ?>
<ul id="process"><span>Additional Shots</span>
</ul>
<br>
<?php endif; ?> <?php } ?>
}
?>
remove opening php tags like:
change:
to
and similarly in
elseif
Added:
As MarcB comments – popping in and out of PHP like this is not ideal. The alternative syntax is great if you are writing a predominantly HTML based file with some PHP injection, otherwise I’d use something like a HEREDOC to make things more easy to spot: