Ultimate Facebook Comments: different width?

Hello,

how can I apply different sizes for the Facebook Comments box? My pages are in a 2 column layout, my posts in a 3 column layout. And I want people to be able to write comments on both… In the settings of Ultimate Facebook I can only enter one single width in pixels for the Facebook Comments box. So it always only looks good in one layout… Any ideas?

Thanks in advance,

Eike

  • Arun Basil Lal
    • New Recruit

    Hey Eike,

    This is interesting, and here is a way I can think of doing it.

    Set the comments box width to the lesser of the two widths in the Facebook settings. Now use the custom hook part and enter a custom hook name in the settings, something like “my_action_name”. (without the quotes of course, and use something that wouldn’t conflict with anything else).

    Now in your theme files, open up page.php and single.php and add this replacing the call to comment template with:

    <?php do_action("my_action_name");?>

    Please give me a link to your site when this is done, a css fix can elongate it on the wider one I suppose, will give you that after this.

    Am not sure how much you follow this, feel free to ask any more questions. Good luck!

  • eike_adler
    • WPMU DEV Initiate

    Hey Arun.

    Well, its not that easy. The page and single phps are basically empty, layout is done via the theme. “Layouts are created in the theme options and “design-{name}.php” files” it says there…

    I use the Salutation theme from Parallelus…

    The hook is already in use, i put do_action("my_comments_action"); in the comments.php and added “my_comments_action” as a custom hook to get facebook comments to work. So what’s next? :wink:

  • Arun Basil Lal
    • New Recruit

    Let me try a different approach in that case, try this:

    <?php
    if (is_page()) { ?>
    <div style="width: 400px !important;" class="composer"><?php do_action("my_comments_action"); ?></div><?php }
    else {
    do_action("my_comments_action"); }
    ?>

    Try adding this to comments.php . Change 400px to what you want for pages.

    btw, the deactivate the WP comments, delete the call to the comments box in comments.php. There should be something in there, right?

  • eike_adler
    • WPMU DEV Initiate

    Unfortunately, this didn’t work. I pasted your code in the comments.php but the facebook comments box is not different.

    Maybe I did something wrong?

    <?php
    // Do not delete these lines
    if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die ('Sorry, you can't load this page directly.');
    // Do we have comments OR are comments at least open
    if ( have_comments() || 'open' == $post->comment_status) : ?>
    <!-- Post Comments -->
    <?php
    if (is_page()) { ?>
    <div style="width: 680px !important;" class="composer"><?php do_action("fbcommentshook"); ?></div><?php }
    else {
    do_action("fbcommentshook"); }
    ?>
    <div class="userComments" id="Comments">
    <div id="comments" class="hidden"></div>

    <?php
    // Show a title "Comments" for the section
    if ( have_comments() ) :
    echo '<h4 class="sectionTitle">' . __('Comments', THEME_NAME) . '</h4>';
    endif;

  • Arun Basil Lal
    • New Recruit

    Are the comment forms appearing properly? is it just the width is different?

    As a test, try this:

    <?php

    if (is_page()) { ?>

    <div style=”width: 680px !important;” class=”composer”><?php do_action(“fbcommentshook”:wink:; echo “This is Page”; ?></div><?php }

    else {

    do_action(“fbcommentshook”:wink:; echo “This is not page”; }

    ?>

    Also give me links where I can see it for real, if you do not want to make the links public, please email them to arun [at] incsub.com .

    Also mention the link to this thread so that I can follow-up: https://premium.wpmudev.org/forums/topic/ultimate-facebook-comments-different-width

    Looking forward to it.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.