Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help rearranging this code (for Wordpress single.php)

    I need help with rearranging the code in my single.php file for my premium theme on Wordpress.

    Currently, posts on my Wordpress site feature a Facebook comment box in the Related Posts section, with the default Wordpress comment box under the Leave A Comment section. I would like to either remove the default Wordpress comment box completely and replace it with the Facebook one (so that it is under the Leave A Comment heading), or I would like to have both the Facebook and Wordpress comment boxes under the Leave A Comment heading, with the Facebook one appearing on top.

    PHP Code:
    <?php
        get_header
    ();
        global 
    $bd_data;
        
    $bd_criteria_display get_post_meta(get_the_ID(), 'bd_criteria_display'true);

        
    /* Side bar */
        
    global $post;
        if( 
    get_post_meta$post->ID'bd_full_width'true ) ){
            
    $post_full      ' post_full_width';
        } elseif(
    get_post_meta($post->ID'bd_sidebar_position'true) == 'left'){
            
    $post_po        ' post_sidebar_left';
        } elseif(
    get_post_meta($post->ID'bd_sidebar_position'true) == 'right') {
            
    $post_po        ' post_sidebar_right';
        }
    ?>
        <div class="<?php echo $post_po; echo $post_full ?>">
        <div class="content-wrapper">
            <div class="inner">
            <?php bd_breadcrumb(); ?>
            <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                <article <?php post_class('article'); ?> id="post-<?php the_ID(); ?>">
                    <?php echo bd_post_top(); ?>
                    <div class="clearfix"></div>
                    <h2 class="post-title">
                        <?php the_title(); ?>
                    </h2><!--/post-title/-->
                    <?php echo"<div class='clearfix'></div> \n"; echo bd_post_meta(); ?>
                    <?php echo bd_post_above_ads(); ?>
                    <div class="post-entry bottom40">
                        <?php
                            
    if( $bd_criteria_display == 't' ){
                                
    bd_post_rate();
                            }
                        
    ?>
                        <?php the_content(); ?>
                        <?php wp_link_pages(); ?>
                        <?php
                            
    if($bd_criteria_display == 'bottom'){
                                
    bd_post_rate();
                            }
                        
    ?>
                    </div>

                    <?php
                        $bd_post_the_exporter           
    get_post_metaget_the_ID(), 'bd_post_the_exporter'true );
                        
    $bd_post_the_exporter_link      get_post_metaget_the_ID(), 'bd_post_the_exporter_link'true );
                        
    $bd_post_image_exporter         get_post_metaget_the_ID(), 'bd_post_image_exporter'true );
                        
    $bd_post_image_exporter_link    get_post_metaget_the_ID(), 'bd_post_image_exporter_link'true );
                        if( !empty( 
    $bd_post_the_exporter_link ) || !empty( $bd_post_image_exporter_link ) ) {
                    
    ?>
                        <div class="the-exporter">
                            <?php if( !empty( $bd_post_the_exporter_link ) ) { ?>
                            <a href="<?php echo $bd_post_the_exporter_link ?>" class="" target="_blank"><?php if( $bd_post_the_exporter ) { echo $bd_post_the_exporter; } else { _e'Exporter article''bd' ); } ?></a>
                            <?php ?>
                            <?php if( !empty( $bd_post_image_exporter_link ) ) { ?>
                                <a href="<?php echo $bd_post_image_exporter_link ?>" class="" target="_blank"><?php if( $bd_post_image_exporter ) { echo $bd_post_image_exporter; } else { _e'Image exporter article''bd' ); } ?></a>
                            <?php ?>
                        </div>
                    <?php ?>

                    <?php if($bd_data['post_tags']): ?>
                        <div class="clear"></div>
                        <div class="post-tags">
                            <b><?php _e('Tags ','bd'?></b>
                            <?php the_tags(' '', '' '); ?>
                        </div><!-- .post-tags/-->
                    <?php endif; ?>
                    <?php echo bd_post_below_ads() ?>
                    <?php bd_in ('social-sharing'); // Get Social Sharing ?>
                    <?php if($bd_data['post_pagination']): ?>
                        <div class="post-navigation">
                            <span class="post-nav-left"><?php previous_post_link('%link'__('<i class="icon-chevron-left"></i> &nbsp; Previous''bd')); ?></span>
                            <span class="post-nav-right"><?php next_post_link('%link'__('Next &nbsp; <i class="icon-chevron-right"></i>''bd')); ?></span>
                        </div>
                    <?php endif; ?>
                    <?php if($bd_data['post_author_box']): ?>
                        <div class="post-author-box">
                            <div class="box-title"><h2><b><?php _e'About the : ''bd' ?> <?php the_author_posts_link(); ?></b></h2></div>
                            <?php echo bd_author_box() ?>
                        </div>
                    <?php endif; ?>
                    <?php bd_in ('related-posts'); // Get Related Posts ?>
                    
    <?php
                        $bd_hide_comments_post_page 
    get_post_meta(get_the_ID(), 'bd_hide_comments_post_page'true);
                        if( ( empty( 
    $bd_hide_comments_post_page ) ) || $bd_hide_comments_post_page == 'yes' ){ 
                            if(
    $bd_data['post_comments_box']){
                                
    wp_reset_query(); comments_template();
                            }
                            if(
    $bd_data['post_fb_comments_box']){
                                
    ?>
                                <div id="fb-root"></div>
                                <script>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];  if (d.getElementById(id)) return;  js = d.createElement(s); js.id = id;  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";  fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
                                <?php
                                
    // Get the current page url for FB comments
                                
    $url = (!empty($_SERVER['HTTPS'])) ? "https://" $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] : "http://" $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
                                echo 
    '<div class="fb-comments" data-href="'$url .'" data-num-posts="4" data-width="690"></div>' ."\n";
                            }
                        }
                    
    ?>

                </article>
            <?php endwhile;?>
            <div class="clear"></div>
            </div>
        </div><!-- .content-wrapper/-->
        <?php
            
    if(get_post_meta($post->ID'bd_full_width'true)){
            } else {
                
    get_sidebar();
            }
        
    ?>
        <div class="clear"></div>
    </div>
    <?php get_footer(); ?>
    If you're having a hard time reading the php as pasted, it's also attached in a .zip folder.

    Now here's the suggestion/"hint" I received from the theme's developer about this matter.

    Go to single.php Go to line 83

    This code is FB: if($bd_data['post_fb_comments_box']){ ?> (function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); ' ."\n"; }

    ==================

    This code is wordpress:

    if($bd_data['post_comments_box']){ wp_reset_query(); comments_template(); }
    Also, here's an example of a post on my website with the comment boxes.

    If anyone could rearrange the code as I described and either upload the .php and send me a link to it or post it here I guess, that would be a great help. Thanks in advance.
    Attached Files Attached Files

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,081
    Thanks
    23
    Thanked 592 Times in 591 Posts
    Few people here use wordpress. You would get better faster results going to their forums or google "wordpress help"
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    New Coder
    Join Date
    Dec 2013
    Location
    Were my backpack is!
    Posts
    20
    Thanks
    3
    Thanked 0 Times in 0 Posts
    You should be able to do this with custom CSS. You can eather create a child theme (pretty simple), or most themes have a CSS editor.

    You should not edit you theme files because when an update occurs they will be returned to default. (unless this is your child themes php files)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •