• Resolved Deepak Mittal

    (@deepak-mittal)


    This plugin works great on a normal page, but fails to display files (any type) when the page is using any custom template other than the default template(index.php)

    When [gview file=”http://www.yoururl.com/doc.pdf”%5D is used on custom template then it shows this shortcode instead of showing the actual document.

    I just copy pasted the entire code from default template (index.php) to my
    custom template (say GoogleDoc.php) and put the shortcode in it. But its not working. Where as the same code present in “index.php” is working fine.

    The only difference between these two template is the custom template name code (as given below) placed at top, which is not present in index.php.

    <?php
    /*
    Template Name: GoogleDoc
    */
    ?>

    Please help.

    http://wordpress.org/extend/plugins/google-document-embedder/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The shortcodes in my plugin work as any others would. If you’re using another template you can try to use the do_shortcode function instead:

    <?php do_shortcode ([gview...]); ?>

    If you find that doesn’t work for some reason, do let me know. If this is not what you intend, please explain what you’re wanting to do better, and ideally show a plugin that does what you’re expecting with a shortcode. Thanks.

    Thread Starter Deepak Mittal

    (@deepak-mittal)

    Hi k3davis,
    Thanks for the quick reply. But I am still not getting it correct. Here are the steps I followed:

    1. I created a template page “GoogleDoc.php” in which [gview…] definition is hardcoded in body tag.
    eg. <body>[gview file=”http://www.yoururl.com/doc.pdf”%5D</body&gt;

    Other codes : <?php get_header(); ?> <?php get_footer(); ?> etc. are also intact as in default template(index.php)

    2. Now, I created a blank page using “Add New Page” in WP and assigned it above template (GoogleDoc). When previewing it failed to display the document.

    Result:
    I am getting below text instead of the document:
    [gview file=”http://www.yoururl.com/doc.pdf”%5D

    I also tried using below code, but it also failed:
    <?php do_shortcode([gview file=”http://www.yoururl.com/doc.pdf”%5D); ?>

    I am not much of tech guy and have no idea how do_shortcode function will behave. Please let me know if I am missing any other detail.

    Hi Deepak,

    I think I added confusion in my answer rather than clear it up. Please try the following code instead:

    <?php echo do_shortcode('[gview file="http://www.yoururl.com/doc.pdf"]'); ?>

    Note the “echo” which I neglected in my first response.

    If this does not work, please give me the following info – you may do so ere or privately within the support link on your plugin list:

    * The URL of the file you’re trying to embed
    * Any error message you receive (if not just the shortcode printing out) – also check the HTML comments of the page at the location the viewer is being called if nothing appears for messages – view the source of the page and search for “gde” for quick access.

    Hope this helps.

    Kevin

    Thread Starter Deepak Mittal

    (@deepak-mittal)

    A big thank you Kevin.
    The above code with echo is working fine now.

    Deepak

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Google Doc Embedder] gview code link in custom template is not working’ is closed to new replies.