WordPress.org

Ready to get started?Download WordPress

Forums

Google Doc Embedder
[resolved] gview code link in custom template is not working (5 posts)

  1. Deepak Mittal
    Member
    Posted 2 years ago #

    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"] 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/

  2. k3davis
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  3. Deepak Mittal
    Member
    Posted 2 years ago #

    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"]</body>

    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"]

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

    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.

  4. k3davis
    Member
    Plugin Author

    Posted 2 years ago #

    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

  5. Deepak Mittal
    Member
    Posted 2 years ago #

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

    Deepak

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic