2
votes

Well what I am trying to do is add a barcode to my wordpress sidebar. The plugin used to generate the barcode is called Yeblon

Yeblon Plugin Page

the shortcode used by the plugin is

[yeblonqrcode size="100" url="" class="" style=""]

were url is the place were the generated barcode leads to

The url I want to generate is inserted from the custom fields. I use a plugin called Advanced Custom Fields.

Advanced Custom Fields Plugin Page

the code that displays the link is

<?php the_field("download_(android)" , $post->ID); ?>

So my final code is

        <div id="mobile-barcodes-tabs">
        <?php $post = $wp_query->post; ?>
        <?php
        if(get_field('download_(android)')){ ?>
            <?php echo do_shortcode('[yeblonqrcode size="100" url="the_field("download_(android)" , $post->ID);" class="" style=""] ');?>
        <?php }
        ?>
    </div>

But it is not working I don't know what is the problem I will be glad if you helped me thanks in advance

1
Can you try being more specific than "it is not working"? do you get an error? - Matanya

1 Answers

4
votes

Build the PHP values beforehand and use string concatenation:

<div id="mobile-barcodes-tabs">
    <?php 
    $post = $wp_query->post;   
    $the_url = get_field( 'download_(android)' , $post->ID );   
    if( $the_url ) {            
        echo do_shortcode( '[yeblonqrcode size="100" url="' . $the_url . '" class="" style=""]' );
     }
    ?>
</div>

PS: You probably noticed that I removed all those unnecessary opening and closing PHP tags.