2

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? Commented Dec 22, 2012 at 22:01

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.