Viewing 2 replies - 1 through 2 (of 2 total)
  • I had to get some band reviews that were already in Disqus from from my old site into my new WordPress band site. I only wanted the reviews on our home page so here’s what I did…

    I looked at the code on my old site and grabbed the disqus_identifier value from there.

    I went to add a custom field to the home page. To my surprise in the list there was already a custom field there named dsq_thread_id. So I added that custom field and gave it the disqus_identifier value from my old site.

    I’m new to WordPress and PHP so this is probably bad a bad idea, but I needed to get this done, so I edited the Disqus plugin’s comment.php by adding this code after all the var initialization…

    <?php if ( get_post_meta($post->ID, 'dsq_thread_id', true) ) : ?>
            disqus_identifier = '<?php echo get_post_meta($post->ID, 'dsq_thread_id', true); ?>';
        <?php endif; ?>

    BAAAMMM! Worked the first time…

    If you have any ideas about how to get this to work without changing the Disqus plugin code base, that would rock. I need to take a step back and really think this over after the new site is released in a couple of day.

    -Chris
    https://www.u2act.com

    Okay… that was a bad idea… sort of…

    The dsq_thread_id is a reserved field. It was overwritten and my reviews stopped showing up.

    So I defined and added a custom field named “dsq_identifier” and gave it the disqus_identifier value from my old site.

    I then corrected the Disqus plugin’s comment.php as follows…

    <?php if ( get_post_meta($post->ID, 'dsq_thread_id', true) ) : ?>
            disqus_identifier = '<?php echo get_post_meta($post->ID, 'dsq_identifier', true); ?>';
    <?php endif; ?>

    One other thing I forgot to mention was that I modified my custom template which used by several pages. I only want to display the review comments on our home page which has the custom field named “dsq_identifier.” Here’s that code…

    <?php if ( get_post_meta($post->ID, 'dsq_identifier', true) ) : ?>
        <?php comments_template(); ?>?
    <?php endif; ?>

    -Chris
    https://www.u2act.com

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘override disqus_identifier’ is closed to new replies.