php inside php to display gallery conditionally not working
-
Hi, I am trying to display a div with a picture gallery for some posts only that have a certain tag, and another div with other content for other posts that do not have that tag but have another. However, it is not working.
This is the query I adapted from https://codex.www.ads-software.com/Template_Tags/get_the_tags (Display code bases on different tag values). I am not using it in the loop. I tried using it in the loop, but it won’t work.
<?php if ($all_the_tags); $all_the_tags = get_the_tags(); foreach($all_the_tags as $this_tag) if ($this_tag->name == "show-gal" ) { ?> <div> <?php $gal = get_post_meta($post->ID, 'galleryflash', true); $gal = apply_filters('the_content', $gal ); echo $gal; ?> <?php $gal = get_post_meta($post->ID, 'gallerypopup', true); $gal = apply_filters('the_content', $gal ); echo $gal; ?> </div> <?php } else if ($this_tag->name == "no-show-gal" ) { ?> **ALTERNATE CONTENT HERE** <?php } else { // it's neither, do nothing ?> <!-- not tagged as one or the other --> <? } } ?>
The error I get is the following:
Parse error: syntax error, unexpected ‘}’ in /home/user/public_html/wp-content/themes/theme/single.php on line 176
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘php inside php to display gallery conditionally not working’ is closed to new replies.