Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Comments, trackbacks & pings (http://forum.bytesforall.com/forumdisplay.php?f=19)
-   -   [SOLVED] Making a separate header for the trackbacks? (http://forum.bytesforall.com/showthread.php?t=6585)

jankph Apr 3, 2010 10:36 PM

[SOLVED] Making a separate header for the trackbacks?
 
While it is great to have trackbacks and pingbacks separated from the rest of the comments, i.e. trackbacks below comments, is there a way to clearly identify them as trackbacks, i.e. with a header that says "trackbacks"?

1. Is it possible to insert a "Trackbacks" header before the trackbacks?

2. Is there a way to make it say "XX comments to ..." and then "YY trackbacks to...", taking into account the different numbers?

3. If neither 1 or 2 are possible, where can I change "XX comments to..." into XX reactions to..." since a trackback is not a comment and it thus makes more sense to call he whole thing reactions rather than comments as to not confuse the readers.

Thanks for your help.

Edit:
I managed to figure out #3 but I would also like #1 to work, #2 would be better, though.

jankph Apr 8, 2010 02:06 PM

Just bumping my own thread here.

What I am looking for is a way to insert "Trackback" above the trackbacks/pingbacks. Right now it's like this below the post, e.g.

6 reactions to post title
comment 1
reply 1
comment 2
reply 2
trackback 1
trackback 2


I want it to be

6 reactions to post title
comments
comment 1
reply 1
comment 2
reply 2
trackbacks
trackback 1
trackback 2


It should be very simple, just inserting a line of text somewhere in the php, but where?


Ideally, it should be

4 comments to post title
comment 1
reply 1
comment 2
reply 2
2 trackbacks to post title
trackback 1
trackback 2


How can I make that?

derekwbeck Jan 10, 2011 10:03 PM

In the comments.php, which you can find in the editor option in WP underneath the ATA options, find the code

Code:

                wp_list_comments(array(
                        'avatar_size'=>$bfa_ata['avatar_size'],
                        'reply_text'=>__(' · Reply','atahualpa'),
                        'login_text'=>__('Log in to Reply','atahualpa'),
                        'callback' => bfa_comments,
                        'type' => 'comment'
                        ));

                wp_list_comments(array(
                        'avatar_size'=>$bfa_ata['avatar_size'],
                        'reply_text'=>__(' · Reply','atahualpa'),
                        'login_text'=>__('Log in to Reply','atahualpa'),
                        'callback' => bfa_comments,
                        'type' => 'pings'
                        ));

and insert between the two the following:

Code:

                echo "any HTML or text here, such as Trackbacks";
that will do it. Be sure to keep a local copy of this add-in, as it may be replaced with future upgrades of the ATA theme.

Note, this assumes you have, in the ATA>Comments settings, comments set up to separate trackbacks/pingbacks out.

derek
www.1775thebook.com

derekwbeck Jan 10, 2011 11:13 PM

Okay, I've been toying with this on my own site, and following the suggestions of http://wphacks.com/separating-trackb...wordpress-2-7/

here's what I did (using ATA 3.5.3 and WP 3.0.4):

In the comments.php as noted above, I removed the above code, and replaced it with:

Code:

        <?php // Do this for every comment
        if ($bfa_ata['separate_trackbacks'] == "Yes") {

                //add-in by derek beck for
                //from www.wphacks.com/separating-trackbacks-from-comments-in-wordpress-2-7/

                wp_list_comments(array(
                        'avatar_size'=>$bfa_ata['avatar_size'],
                        'reply_text'=>__(' &middot; Reply','atahualpa'),
                        'login_text'=>__('Log in to Reply','atahualpa'),
                        'callback' => bfa_comments,
                        'type' => 'comment'
                        ));

                echo "<BR><h3 id='comments'>Trackbacks:</h3>";
                echo "<div id='pings'>";

                wp_list_comments('type=pings&callback=list_pings');
               
                echo "</div>";

                //end add-in
        } else {

The id=comments for the trackbacks header makes it the same css formats as the comments title above it. The div id=pings is useful for customized css, as noted below.

In the functions.php, I put the following at the bottom of the existing functions.php:

Code:

<?php 

//add-in by derek beck for
//from www.wphacks.com/separating-trackbacks-from-comments-in-wordpress-2-7/
               
function list_pings($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
?>
<li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?>
<?php } ?>
<?php
add_filter('get_comments_number', 'comment_count', 0);
function comment_count( $count ) {
if ( ! is_admin() ) {
global $id;
$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
//end add-in
?>

Finally, in the ATA settings, CSS Inserts, I added the following CSS, which I've commented out a few things, but you get the idea on how to change stuff:

Code:

div#pings li {
        position: relative;
        left: 10px;
        font-size: 0.8em !important;       
        font-weight: normal !important;
        margin-bottom: 4px !important;
}
div#pings li a:visited, div#pings li a:link {
        /*color: #663333;*/
        font-weight: normal !important;
}
div#pings li a:hover, div#pings li a:active {
        /*same as default links*/
        /*color: #CC0000;*/       
        font-weight: normal !important;
}

The result can be seen at http://www.derekbeck.com/1775/info/british-christmas/

hope that helps someone!

tattvaanveShaNam Feb 7, 2012 05:31 PM

I created a Atahualpa child theme and copied over the comments.php and functions.php to the child theme directory with the intent to make these edits in those files. However, the presence of functions.php causes the site to not load. I don't wish to edit the theme files in the parent Atahualpa folder since an upgrade will ease those edits. I already have a edited index.php in the child theme folder and that works fine. Any suggestions on the functions.php?

juggledad Feb 7, 2012 06:18 PM

You need to go back and read about child themes.
HTML Code:

Unlike style.css, the functions.php of a child theme does not override its counterpart from the parent.
Instead, it is loaded in addition to the parent’s functions.php. (Specifically, it is loaded right
before the parent’s file.)

taken from http://codex.wordpress.org/Child_Themes

tattvaanveShaNam Feb 7, 2012 06:48 PM

@juddledad, thanks for pointing me in the right direction.

tattvaanveShaNam Feb 7, 2012 11:44 PM

How do I make the "Pingbacks/Trackbacks:" text conditional? Using the nested conditional results in the comments+comment form and the sidebars to vanish. (pardon my lack of php skills)

Quote:

<?php // Do this for every comment
if ($bfa_ata['separate_trackbacks'] == "Yes") {

wp_list_comments(array(
'avatar_size'=>$bfa_ata['avatar_size'],
'reply_text'=>__(' &middot; Reply','atahualpa'),
'login_text'=>__('Log in to Reply','atahualpa'),
'callback' => 'bfa_comments',
'type' => 'comment'
));

if ( ! empty($comments_by_type['pings']) ) {
echo "<h3 id="pings">Pingbacks/Trackbacks:</h3>";
<ol class="pinglist">
<?php wp_list_comments('type=pings&callback=list_pings') ;
</ol>
}


} else {

wp_list_comments(array(
'avatar_size'=>$bfa_ata['avatar_size'],
'reply_text'=>__(' &middot; Reply','atahualpa'),
'login_text'=>__('Log in to Reply','atahualpa'),
'callback' => 'bfa_comments',
'type' => 'all'
));

} ?>

juggledad Feb 8, 2012 05:37 AM

You have to pay attention to when you are in PHP and when handling HTML, try this
HTML Code:

<?php // Do this for every comment
if ($bfa_ata['separate_trackbacks'] == "Yes") {

        wp_list_comments(array(
        'avatar_size'=>
$bfa_ata['avatar_size'],
        'reply_text'=>__(' &middot; Reply','atahualpa'),
        'login_text'=>__('Log in to Reply','atahualpa'),
        'callback' => 'bfa_comments',
        'type' => 'comment'
        ));

        if ( ! empty($comments_by_type['pings']) ) { ?>
                <h3 id="pings">Pingbacks/Trackbacks:</h3>
                <ol class="pinglist">
                <?php wp_list_comments('type=pings&callback=list_pings'); ?>
                </ol>
                <?php }       
        else {
                wp_list_comments(array(
                'avatar_size'=>
$bfa_ata['avatar_size'],
                'reply_text'=>__(' &middot; Reply','atahualpa'),
                'login_text'=>__('Log in to Reply','atahualpa'),
                'callback' => 'bfa_comments',
                'type' => 'all'
                ));
        }
} ?>


tattvaanveShaNam Feb 8, 2012 09:48 PM

@juddledad, Thanks. I had to slightly modify your modification, but here is the final version:


PHP Code:

<?php // Do this for every comment
    
if ($bfa_ata['separate_trackbacks'] == "Yes") {

        
wp_list_comments(array(
        
'avatar_size'=>$bfa_ata['avatar_size'],
        
'reply_text'=>__(' &middot; Reply','atahualpa'),
        
'login_text'=>__('Log in to Reply','atahualpa'),
        
'callback' => 'bfa_comments'
        
'type' => 'comment'
        
));

        
$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' $id));
        if ( ! empty(
$comments_by_type['pings']) ) { ?>
            <h3 id='pings'>Pingbacks/Trackbacks:</h3>
            <div id='pings'>
            <ol class="pinglist">
                <?php wp_list_comments('type=pings&callback=list_pings'); ?>
            </ol>
            <?php }    
    }
    else {
        
wp_list_comments(array(
        
'avatar_size'=>$bfa_ata['avatar_size'],
        
'reply_text'=>__(' &middot; Reply','atahualpa'),
        
'login_text'=>__('Log in to Reply','atahualpa'),
        
'callback' => 'bfa_comments'
        
'type' => 'all'
        
));
    }
?>



All times are GMT -6. The time now is 08:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.