WordPress.org

Support

Support » Plugins and Hacks » New amazon item not looked up/ added to cache with custom post type?

New amazon item not looked up/ added to cache with custom post type?

Viewing 1 replies (of 1 total)
  • 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 yourdomain.com/wp-content/plugins/wordpress-amazon-associate/APaPi/AmazonProduct/Item.php 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.