Forums

[resolved] [Plugin: WP Publication Archive] Fatal error on template tag but shortcode works (4 posts)

  1. andydarley
    Member
    Posted 1 year ago #

    Hi Eric -

    I'm trying to use this plugin on a client's site where document management is vital. On the test server I can get the plugin to work as a short code, but not as a PHP template tag - and, unfortunately, that's how I need it to work.

    I add it to the source like this:
    ` <h3>Recent website updates</h3>
    <ul>
    <?php wp_publication_archive(); ?>
    </ul>`
    And get this on the page:

    Fatal error: Call to undefined function wp_publication_archive() in /var/www/virtual/www/CLIENTSITENAME/wp-content/themes/2011new/sidebar.php on line 71

    I've also tried it as WP_Publication_Archive since that looks like how it is in the plugin file, but no success.

    Do you have any suggestions why this should be, or where I should start looking?

    Two other questions:
    1. Is it possible to filter the template tag by categories, in the same way the shortcode can be? (Ideally I'd rather do it by tag but I don't think that's available at all, is it?)
    2. Is it possible to show only the icon, file title and 'download' link - no other data - without having to hack the plugin code? I suspect it's not...

    Many thanks in advance for any help you can give, and obviously ask anything you need to clarify what I'm asking. I can't show you the site, I'm afraid, as it's locked away on a private test server.

    Andy

  2. Eric Mann
    Member
    Posted 1 year ago #

    My recommendation would be to use do_shortcode() in your PHP text. If you do that, you can use the exact same syntax and information you'd use otherwise.

    For example:

    <?php
        echo do_shortcode( '[wp-publication-archive categories="cat-1" /]' );
    ?>
  3. Eric Mann
    Member
    Posted 1 year ago #

    Just remember, there aren't any template tags that ship with this plugin by default ... so wp_publication_archive() isn't supposed to work (and doesn't exist in the global namespace anyway).

    If you want to call the function that renders the shortcode content directly, call WP_Publication_Archive::shortcode_handler(). Just be sure to pass in your parameters as needed ("categories" and "author").

  4. andydarley
    Member
    Posted 1 year ago #

    See, this is where being CSS-and-HTML-only lets me down. I didn't know do_shortcode even existed...

    That worked, thank you very much - on both efficiency and speed.

Topic Closed

This topic has been closed to new replies.

About this Topic