Support

Account

Home Forums Add-ons Repeater Field If Elseif Else Question

Helping

If Elseif Else Question

  • Hello,
    I would like to show a PDF link for each town.

    I have this code but it don’t working.

    <?php if(get_field('pdf_paris')){ ?><h2><a href="<?php  the_field('pdf_paris') ?>" target="_blank">Download <br />the PDF for Paris</a>
    
    else if(get_field('pdf_marseille')){ ?><a href="<?php  the_field('pdf_marseille') ?>" target="_blank">Download <br />the PDF for Marseille</a>
    
    else ?>
    No PDF available.
    <?php } ?>

    Thx for your support :)!

  • Try this:

    <?php 
    
    if(get_field('pdf_paris')){
    	$pdfParis =  get_field('pdf_paris');
    	echo'<h2><a href="'.$pdfParis.'" target="_blank">Download <br />the PDF for Paris</a></h2>';
    else if(get_field('pdf_marseille')){ 
    	$pdfMars =  get_field('pdf_marseille');
    	echo'<a href="'. $pdfMars.'" target="_blank">Download <br />the PDF for Marseille</a>';
    
    else {
    	echo'No PDF available.';
    }
    
    ?>

    Have fun!

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘If Elseif Else Question’ is closed to new replies.