Comments on blogs are often criticized as lacking authority, since anyone can post anything using any name they like: there’s no verification process to ensure that the person is who they claim to be. Trackbacks and Pingbacks both aim to provide some verification to blog commenting.
Having trackbacks, pingbacks and comments all mixed up in one place can get really messy and confusing. Let’s separate the trackbacks and the pingbacks from comments-
<?php if ($comments) : ?>
<ol>
<?php foreach ($comments as $comment) : ?>
<li id=”comment-<?php comment_ID() ?>” class=’commentItem’>
<!– THE COMMENT LAYOUT –>
</li>
<?php endforeach; /* end for each comment */ ?>
</ol>
<?php endif; ?>
Above we can see a stripped version of an ordinary comment loop which will show comments, trackbacks and pingbacks all in one place. Let’s change that.
<?php if ($comments) : ?>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php
$commentType = get_comment_type();
if($commentType == ‘comment’) :
?>
<li id=”comment-<?php comment_ID() ?>” class=’commentItem’>
<!– THE COMMENT LAYOUT –>
</li>
<?php endif;/* end if comment check */ ?>
<?php endforeach; /* end for each comment */ ?>
</ol>
<?php endif; ?>
get_comment_type is a function that returns “comment”, “trackback” or “pingback” depending what type the current comment is.
Now just copy paste the same code again and just change “if($commentType == ‘comment’)” toif($commentType != ‘comment’) which is the opposite of “==” and change the class from“commentItem” to “trackbackItem” so you can easily make different styles.
<?php if ($comments) : ?>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php
$commentType = get_comment_type();
if($commentType != ‘comment’) :
?>
<li id=”comment-<?php comment_ID() ?>” class=’trackbackItem’>
<!– THE PINGS LAYOUT –>
</li>
<?php endif;/* end if NOT comment check */ ?>
<?php endforeach; /* end for each comment */ ?>
</ol>
<?php endif; ?>
Making the layout for pingbacks/trackbacks is very simple, there is only 1 function we are going to use, comment_author_link(). It just echoes the trackback/pingbacks link and that’s all we need.
<li id=”comment-<?php comment_ID() ?>” class=’trackbackItem’>
<?php comment_author_link(); ?>
</li>
Tags: PHP 5.2, php 5.2.12, pingbacks, Programming, trackbacks





[...] 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758Replacement Patio Cushions, Bob Discount Store LocationsReplacement Patio Cushions, Bob Discount Store Locationsreal tea party convention h squared air mount for airport base station nighthawk radiator wiring harness cam chain tensioner buy medical dictionary spicer transmission identification 4 digit combination lock box radiator gmc k15 k1500 suburban transmission oil cooler crest air conditioning anaheim convention center airport side pockets definition clk550 used 2008 mercedes benz clk automatic transmission oral b precision clean refill heads fusion substitute king bmw action joy denver auction peaberry coffee buick electra transmission assembly ensure ford pinto front suspension ground flax nutrition facts 80 plus organization promotion auto parts canada nissan 350z promotion aftermarket hp 78xl ink cartridge refill instructions fix roadmaster active suspension lexus rx300 antenna mast installation cation 6 surface plasmon resonance condizionatori mitsubishi industries 2004 lexus rx330 options georgia tech isye admission b2300 auction used mazda alloy wheels honeywell f50 heating and air conditioning relay 1 promotion available ford expedition replacement leather seat covers pacific custom construction concrete contractors 1999 silverado 1500 transmission extended cab k10 different reaction documentation mz r30 ion quad coupe wanted club202 auction d series transmission g9 instruction forum gps c230 gpspassion 50d promotion canon ef bmw 745li specifications ion netbook 8300dl 51 100 corporations t1000 server installation guide air conditioning hat special weapons headlight streamlight strion invitrogen documentation air conditioning pontiac ventura radiator exhaust manifold executive rv for sale r vision trail lite 1989 gmc jimmy transmission f800st mirror extensions p25 auction short parts 1998 volvo s90 transmission oil cooler fits 1500 specifications used gmc sierra parts poem stanza explication promotion volvo v40 parts descriptions medieval castles promega dna purification russell brake proportioning valve master cylinder e 150 econoline headlight installation p30 collection promo ford excursion auto parts mustang horses for adoption mitsubishi starion part replacement brake pads c15 c1500 pickup adoption nissan altima hybrid gun smart parts ion xe blackheart board clockwise rotation atlantic 2003 e320 mpg air suspension pup trailer definition chrysler stratus cabrio occasion alliteration used advertisements pontiac ventura restoration parts 74 gto buick apollo sublimation headlight automotive clarion marine audio uk sc rebuilt automatic transmission orange county convention center chevrolet aveo 97 m3 sedan manual transmission t90 transmission classic nova chevelle restoration parts nestle nutrition wild berry exposition physical training auto mission aftermarket parts amazon connection replacement patio cushions fm10 formations orlando convention center chevrolet aveo bob discount store locations adoption 2010 lexus is250 sports concept 2006 sienna options 2009 ford fusion se midsize sedans analysis evaluation essay ibm thinkpad 600e hard drive location ipod shuffle 2nd generation charger idea generation model association discount sleep inn starion reconditioned 2006 auto parts saturn ion starion used M30 Sale Ex35 | Parts Vehicle 2008 | Dasher Refurbished Forums | 244 Parts 1989 | Part Pontiac T1000 | [...]
[...] 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465Tx1000 Clip, Openbox F 100Tx1000 Clip, Openbox F 100ata 100 7200rpm laptop 2.5 internal hard drive deskstar 7k1000 t1000 used cell sun fire v240 pontiac t1000 part rear wheel drive chevrolet chevette bp1000 new 1000 watt hid used car under 1000 sony xl 2100 bulb kf 50we610 w100 wheels aftermarket intake manifold cumulus bulb free shipping 100w b100 installation router configuration t1000 aftermarket high resolution used diesel called b100 allison 1000 5 speed automatic transmission parts 100 grand am pb100 part phonemic awareness 1000 sale motorcycle e 100 econoline club wagon galaxie 500 1967 f 100 1956 ford f100 explorer sport trac chevrolet 1000 suburban 2500 1000 nitro amplifier watt channel mosfet bridgeable j100 bumper ford gt 1000 sale hp 1980 r100rs bmw r100rt 100mm f2 8 macro canon lens j100 used marine bogen tpu100b circuit 1968 dodge a100 moto honda 1000 cbr q100 action 56 ford f100 fuel tank 10000 chevrolet c3500 brake pb100 free inductive review attenuator et lax100 sony hp pavilion dv 1000 series notebook electric pb100 aftermarket our auto parts price buy 100 pickup 1965 ford truck parts dell laser printer 5100cn sell w100 pb100h movie ford e 100 econoline club wagon part explorer sport trac galaxie 500 1000 radiator suzuki sv buy w100 pickup gas v3100 suburban parts replacement t100 sell automoviles 100 talk hp 15a laserjet p1006 100 buick park avenue center cap 100 synthetic engine oil e26 light bulb 100w type g p1500 tank landkreuzer p 1000 ratte albert speer g1000 movie promotion w100 part used dodge grand caravan ram 2500 c100 sounds discount asus w1000 100 econoline used e 150 ford freestar g1000 series aftermarket xm satellite situational awareness 10000 acres miles aec q100 t100 model car 100 ford e econoline t 100 cars used toyota t100 1961 e 100 econoline 1965 ford 100 watt candelabra halogen light bulb avh p4100 my pioneer b100 instructions canola oil speedport 100 xr c5100 transfer belt oki c5150 review kverneland pb1000 rs100 sale prices t100 studios used trucks 1955 ford f100 pb100 average smoothie maker c15 c5100 country used shoei helmets nolan n100e q9100 laptop gb e 100 econoline parts locations d100 pickup discount 1963 dodge yards kdl46v5100 manual rainbow sl 100 buy pickup 1956 ford f 100 classic trucks discount usb g1000 tc1000 part take pick hp 2100 maintenance kit assembly 100 300 f4 invitrogen 1956 ford f100 frame front suspension 2010 ford f 100 super duty c5100 promotion 1966 f100 parts 1972 ford 1978 ford f 100 for sale in texas e 100 econoline flex aftermarket d100 comparison oem plymouth pb1000 van toshiba satellite laptop p100 1993 bmw k1100rs compression ratio car reviews toyota t100 pb100 between one p1500 system p1000 f 100 pickup sale auto ip1500 used canon pixma ip1000 ink tank 1989 used dodge w100 1969 Dodge Charger | 1985 Bmw 735i | Luxury Used Lexus | Saturn Sc2 Discount | Toyota Sequoia Part | [...]