• Resolved challahan

    (@challahan)


    I am using a custom post type to display documents using Google Doc Embedder.

    I’m passing the document URL into a variable called $document and echoing it out. It echoes the URL fine.

    When I try to plug the URL into the shortcode function, though, it drops the file name from the URL. I can’t figure it out.

    I have an example here: http://ideabasekent.com/staging/slo/production/documents/test-document-2/

    Here’s the code I’m using:

    <?php while ( have_posts() ) : the_post(); ?>
    			<h2><?php the_title(); ?></h2>
    			<?php the_field('document_description'); ?>
    			<?php if( get_field('document_file_upload') ):?>
    				<?php $document = the_field('document_file_upload');?>
    				<?php echo $document; ?>
    				<?php echo do_shortcode( '[gview file=" '. $document .' " ]' ); ?>
    			<?php endif; ?>
    <?php endwhile; // end of the loop. ?>

    https://wordpress.org/plugins/google-document-embedder/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter challahan

    (@challahan)

    In case anyone runs into this, I figured it out. I changed the code to:

    <?php if( get_field('document_file_upload') ):?>
    				<?php $document = get_field('document_file_upload');?>
    				<?php echo do_shortcode( '[gview file="'.$document.'"]' ); ?>
    <?php endif; ?>
    Plugin Contributor danlester

    (@danlester)

    Thanks so much for sharing all of this. Glad you found a solution!

    Dan

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trouble with URL Shortcode when executing from template’ is closed to new replies.