Home Forums Add-ons Repeater Field PDF Attachment as Link


PDF Attachment as Link

  • Hello,

    i have a little question. I have a table with to Repeaterfields like:

    | job | location | <- Static Table
    | Developer | Germany | <- Two Fields

    Now i want to link the job (here developer) with an attachment (job pdf).

    The only Option i found, was a new Repeaterfield with Attachment, but these will seperate displayed after the location. I just want to have 2 things in the table with job is linked with an pdf.

    Thank you 🙂

  • Hi @hartu

    Could you please tell me where did you want it to show up?

    If it’s on the front end, I believe you can add a new file custom field to the repeater and then add the link to the job text like this:

    // check if the repeater field has rows of data
    if( have_rows('repeater_field_name') ):
     	// loop through the rows of data
        while ( have_rows('repeater_field_name') ) : the_row();
            // display a sub field value
            $file = get_sub_field('file_sub_field');
            if( $file ):
            <a href="<?php echo $file['url']; ?>"><?php the_sub_field('job_sub_field'); ?></a>
            <?php endif;
    else :
        // no rows found

    I’m afraid you can’t do it on the backend, though. I’m sorry for the inconvenience.

    I hope this helps 🙂

  • Hello James :-)!

    Right it should be show on the Frontend. So i wanna try your Code.
    Thats my code at the moment:
    (I added your Code as a example)

    // Wenn mindestens 1 Datensatz vorhanden ist
    	if( have_rows('stellen_ds_en' , 1779) ) {
    	echo  '<table width="100%">';
    		while( have_rows('stellen_ds_en' , 1779)) : the_row();
    // Bezeichnung aus Feld laden
    	$bezeichnung = get_sub_field('bezeichnung');
    // Ort aus Feld laden
    	$ort = get_sub_field('ort');
    //Here goes your Code? 
            if ( $file ):
            <a href="<?php echo $file['url']; ?>"><?php the_sub_field('bezeichnung'); ?></a>
    // Anhang Text aus Feld laden
    	echo "<tr><td width='50%'>$bezeichnung</td><td width='50%'>$ort</td></tr>";
    // 3 Felder ausgeben
    echo '</table>';
  • Hi @hartu

    I’m not sure which one is the file custom field, so forgive me if I’m wrong (please keep in mind that you need to create a new file custom field in your repeater field). If the file custom field is ‘ort’, you need to do it like this:

    // Ort aus Feld laden
    $ort = get_sub_field('ort');
    //Here goes your Code? 
        if ( $ort ):
        <a href="<?php echo $ort['url']; ?>"><?php the_sub_field('bezeichnung'); ?></a>
        <? endif;

    Also, you need to set the return value of your file custom field to “File Array”. I’ve attached a screenshot for your reference.

    Hope this helps 🙂

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

The topic ‘PDF Attachment as Link’ is closed to new replies.