Comments Plus Shortcode

Hi - I love the comments plus widget. I am trying my best to figure out how to add the comments box to a page of my choosing.

1. Is this possible? i.e. I want to be able to add the comments box selectively to some pages
2. Is there a short code available I can use which will achieve this?

e.g. I would like to add the comments box here:

http://www.fitness-saver.com/fitness-store/scott-foil-premium-2012-road-bike-10201071173045/

(as well as other product detail pages - I have access to the product detail pages, I just need a short code - if there's no short code, maybe a function I can call? )

Kind Regards,
David Hilditch

  • Vladislav

    Hello,

    The Comments Plus plugin works by replacing your standard comments form. This means that you actually can apply it to the pages of your choosing just by allowing or disallowing comments on a page.

    For this same reason, the plugin doesn't use a shortcode or a template tag. To achieve a different placement of the comments and/or comments form (and therefore, the Comments Plus plugin too), you'll have to edit your theme files.

  • 3SixtyEvolve

    @VeBailovity
    Thank you Vladislav for the support! Well explained!

    @dhilditch
    David, I think this answers your question. Please let me know if you need any further support.

    I will resolve this thread, but please don't hesitate to reopen it if you still require additional feedback from our Support Team. Just select the 'Mark as Not Resolved (re-open)' box below the post area (otherwise we might miss your new post).

  • dhilditch

    I've tried this, unfortunately the comments are still not appearing.

    I tried:
    comment_form();
    comments_template();

    and various other attempts, including putting the shortcode hooks on there, which sort of worked - i.e. comments plus form appeared and let me comment but the comment is applied to ALL product details pages.

    I've since figured out more of the problem - the product details pages are virtual pages - i.e. there is no $post or $id value. What I really need is to somehow fake wordpress into believing there is a post and to make up an $id numeric value from the URL.

    I've tried all day to get this to work but still stuck having broken my site multiple times :slight_smile:

    (hey if you don't break your site, you're not really trying! or is that snowboarding?)

    Does anyone have any idea how I might fake wordpress into believing a virtual page is really a post and making up a fake ID for it so that I can get Comments Plus to appear on all my virtual pages?

  • Vladislav

    Hi,

    This is really very dependent on how your products are stored - for an example, if they are custom post types (i.e. they're stored in the posts database table - it's called "wp_posts" by default) you should be pretty much ready to go, maybe with just a few minor tweaks. However, if they're something entirely different, making it work would be much harder. If this is your scenario, it may almost be worth it to autocreate a fake custom post type whenever you create a product, so WordPress has a post to which it can bind the comments to, or even to convert the product to custom post types.

  • dhilditch

    They're something different unfortunately - it's a product called Datafeedr I'm using and it creates virtual pages - i.e. the content is retrieved on the fly from the database and no post actually exists.

    I've found a couple of viable solutions but they're not ideal - the plugins Disqus and Intense Debate both work - it seems they don't use the built in wordpress commenting system and instead key the comments based on the URL which is why they work. BUT, I don't really like either of them - I want my comments system to be integrated with Buddypress, Cubepoints (which will ultimately by tied to Q & A too).

    I was thinking if I could somehow fool wordpress, e.g.:

    1. Use Rand() with the URL path as the seed and get a consistent number between 1 and 100,000 (the max number of products we'll have)
    2. Add 5 million to this number (to ensure real posts don't ever overlap)
    3. Fool wordpress into believing it's on post number 5 million + rand(urlseed)

    If I can achieve all that then I'm pretty sure the posts would appear (depends if there's a DB check against wp_posts to see if the real post exists)

    I can figure out 1 and 2 easily enough but number 3 is eluding me. I love the comments plus style and don't want to have to use crappy Disqus although I read that the Guardian website over here managed to integrate it with Buddypress so maybe that's going to be my only option.

  • dhilditch

    Note - I did find a number of posts on the web about fooling wordpress into believing it's on a post but those seem to be for very old versions of wordpress, before actions, hooks and filters existed.

    I also tried making a copy of the relevant wordpress functions and removing the checks for is_single() and passing in a postid but still that didn't work - I think there's something I'm missing, in that I think I have to fool wordpress at an earlier stage than I'm currently doing.

    I tried add_action ('wp', 'function') and in the function I modified the gloabl $post value but that killed the site :slight_frown:

  • aecnu

    Greetings dhilditch,

    Just checking if this issue was eventually resolved in another thread? Or by yourself separately to us? Or by us over email with you? Or using our live support?

    If so, no need to reply, that's great news.

    If not, or you have any more questions related to this thread, please feel free to post them below including any new symptoms or errors and tick the 'Mark as Not Resolved (re-open)' box below the post area (or else we'll miss it!)

    Otherwise, happy days, glad you got it sorted :slight_smile:

    Thank you for being a WPMU Dev member!

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.