Support » Plugin: WordPress-Amazon-Associate » New amazon item not looked up/ added to cache with custom post type?

  • design_dolphin


    With custom post types it doesn’t seem to add/ lookup the item? Using for example either template or link shortcode.

    Adding a new Amazon item through a normal post works fine. It gets added to the cache when caching is turned on.

    I’m using the TwentryTwelve theme.

    Do I need to register the plugin with the custom post type somewhere?

Viewing 1 replies (of 1 total)
  • design_dolphin


    Not sure what is going on here.

    Managed to get it working, but don’t ask me how or why.

    Debugging steps taken after which it started working:

    The TwentyTwelve theme had a child theme. Within this child theme there was a template file without a loop. In the parent theme there was an old template file for the same custom post type.

    Did a var_dump() of the $atts in amazonTemplateHandler in /WPAA/ShortCodeHandler.php for the template shortcode in a post (e.g. [amazon_template template=”2″ id=”0451463471″]). It would show the var_dump for the shortcode in a normal post, but not in a custom post type.

    Removing both custom post type templates caused the theme to fall back on the single.php of the TwentyTwelve parent theme (the content template files are also in the parent theme, and not overwritten in the child theme). Now when going to a post page it showed the error:

    ‘Fatal error: Call to a member function set() on a non-object in on line 119’

    Tracked this down through var_dump, and came out at /APApi/AmazonProduct/ItemLink.php. In this file I added the following code to class AmazonProduct_ItemLink extends AmazonProduct_Abstract

    function test() {
        echo 'hello';

    After that the plugin started working again. I removed the function test(), and it still works. Uploaded the template for the custom post type again (without a loop) to the child theme and it works. When adding a new Amazon item in a post of a custom post type the item is loaded and added to the cache.

    The problem could possibly be because of one of the following reasons:

    1. Custom post type template
    2. Not having a loop in a (custom post type) template
    3. class AmazonProduct_ItemLink needs a kickstart when a custom post type is added (for the first time?)

Viewing 1 replies (of 1 total)
  • The topic ‘New amazon item not looked up/ added to cache with custom post type?’ is closed to new replies.