• Hi there! Nice plugin, thank you so much for the time taken to develop it and for your support! I’ve been looking through the other threads and its amazing ??

    I’m trying to add an Amazon widget to my site in the hope that someone will ever maybe buy a book. Right now my blog has quite a small audience but I’ve a good deal of post.

    I tried setting the thumbnail shortcode in the sidebar and add some links to a test post and it works, the problem is that going back and populating aaaaall the old posts would be quite time consuming, not sure if worth the effort considering most of them are visited maybe once in a week.

    I thought that I could add a condition in the widget sidebar so that if the post does not match a certain condition (category, has a tag, etc) it loads a predefined widget with maybe my favourite books, wishlist or a single book that I think has the most chances to be bought.

    But even like this, I should tag from now on all the posts that have a certain tag. Using a category to decide would be easier but I don’t like that approach.

    What it would be cool is just let the Widget do an Amazon search by one or all the tags of the post automatically so hopefully it would return a result that will be more or less relevant to the current post. So if I do not want to invest any time in managing the products for a post it’ll still show something at chance.

    I did that a year ago on an ASP project and seemed to work quite well, results were more or less relevant.

    Could it be possible to do something like this with this plugin?

    Ie:

    [amazon text=tag1,tag2,tag3&template=Thumbnail&live=1]

    And in the template something with %POST_TAGS% that would read the tags from the post (tag1,tag2,tag3 etc) and feed them into to the widget for a search?

    Maybe this is already possible somehow and I didn’t realize, sorry if that is the case!

    https://www.ads-software.com/plugins/amazon-link/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author paulstuttard

    (@paulstuttard)

    Hi,

    Thanks for trying the plugin, because it uses a template based system you can pretty much put whatever you want in the keywords and they will be presented in the template.

    It would be possible to extend the plugin to add a new keyword that is populated with say the output from get_the_tag_list. However it sounds like you will probably need to craft some code external to the plugin to really do what you want.

    The plugin is not really set up to do conditional stuff, i.e. do a search widget with these arguments, or if no terms then display a bunch of thumbnails with theses ASINS, etc.

    Have to admit I don’t know if the stuff in the sidebar has awareness of the ‘current post’, e.g. You might be viewing the front page or a category archive which has lots of posts.

    So I think what you want to do has three stages:

    1/ In the sidebar try and deduce a set of tags that is related to the post or posts currently displayed on the page.

    2/ If there are some tags then create a shortcode that is past to the Amazon Link plugin to generate some content.

    3/ If there aren’t any tags then use a default shortcode that is past to the Amazon Link plugin to generate some content.

    The first part of this is the hardest, once you have the shortcode the plugin will probably do what you need. It currently supports the following options:

    1. Create a static template that has an fixed image or text e.g. ‘Explore on Amazon’ that contains a link to an Amazon search result page that uses the tags as the search terms. (search_text=tag1 tag2&search_link=1)

    2. Perform a search for using the tags and display a list of products (using the specified template) based on the result. (s_title=tag1 tag2&s_index=all)

    3. Insert an ‘Amazon Search‘ widget with the ‘default search term’ populated with the tags. (text1=tag1 tag2&template=search widget)

    I can provide more details if any of this is what you are thinking of.

    Paul

    Thread Starter Albert Calvet

    (@albert-calvet)

    Hi! Thank you so much for such a quick and detailed answer. This would be in fact what I had in mind, I might try it when I have some spare time, thank you again!

    For the time being, what I’ve done is this. It might be of interest to someone else hanging around here looking for some ideas.

    1. I CSS’d a new template in order to accommodate the widget to the look & feel of my blog and to adjust to the sidebar.

    2. I installed the extension ‘Widget Logic’ that extends the Text Widget to support conditional PHP code.

    3. I use the following code to look for Amazon Links on the current post, so if there is any, it will populate a random wishlist widget template like the one you provide in the examples.

    $content = apply_filters( 'the_content', get_the_content() );
    $content = str_replace( ']]>', ']]>', $content );
    
    return (preg_match('/class=\"hidden\-link\"/', $content));

    4. I’ll set up a 2nd widget that looks exactly the same and has a fixed list of items, and just put the same condition, but negated (!preg_match).With this, it will always load one or the other, depending if there are links in the current post. I do this with the regex searching for a certain class ‘hidden-link’.

    5. I attached the ‘hidden-link’ class with display:none to the post text links so they are not visible, and use it like this on a post:

    [amazon asin=8428214867&template=hidden link&new_window=1]

    It’s not as flexible as what I wanted and not a very elegant solution but at least I can decide if I want to invest the time to add links to a post and if not, the default ones will load.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Automatic search based on post tags?’ is closed to new replies.