Connect with us

Tips & Tricks

Display custom url if comment authors url is blank

Published

on

Here is a nifty trick for your comments.php template. If someone comes to your site and leaves a comment but doesn’t leave a url back to there site, the default link that is shown in place of the php code comment_author_url is the current page link.

That might not look good. So, here is a little trick that I just implemented into my site. Besides installing the twittar plugin and pulling Twitter avatars I wanted to use the image itself for the authors url like. But if the author doesn’t have a Twitter avatar or a Gravatar it will display a default Gravatar that I set. If the default Gravatar is shown, usually the author will not leave a url link.

I would like to link the image to Gravatar.com so that they can get an image attached to their email address. So.. here is the code:

<?php if($comment->comment_author_url != "") { ?>
<a href="<?php comment_author_url(); ?>"><?php gravatar(); ?></a>
<?php } else { ?>
<a href="http://gravatar.com" title="Get a Gravatar today!"><?php gravatar(); ?></a>
<?php } ?>
Continue Reading
3 Comments

3 Comments

  1. Pingback: Weekend Links - Jan 16, 2009 | OMNINOGGIN

  2. Pingback: Weekend Roundup #32 » JaypeeOnline // Blogging News & Reviews

  3. arcade games

    March 11, 2009 at 3:13 pm

    very nice idea, it could be an advertising slot.

You must be logged in to post a comment Login

Leave a Reply

Tips & Tricks

Limit the characters that display on the_title

Published

on

Ever wanted to display the title of a post somewhere but limit the amount of characters that are shown? For instance, this post has a very long title, and if I were to use <?php echo the_title() ?> it would show as follows: Limit the characters that display on the_title.

That may not fit well on one line in lets say a widget or small width div. So here is a neat trick you can use:

<?php $title = the_title('','',FALSE); echo substr($title, 0, 11); ?>

Pretty simple huh, just note the bold numbers, in this case 11 character would output like this: Limit the c.

Thanks to Tattershall Way for this snippet.

Continue Reading

Tips & Tricks

Can′t add pagination on WooThemes Thick Theme

Published

on

Everything I have tried has led to nothing. And I have tried six way’s from Sunday to get my main posts to paginate.

example one:

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
query_posts('offset=1&showposts=' . get_option('woo_other_entries') . '&cat=-' . $GLOBALS['ex_asides'] . '&paged=$paged' ); ?>

example two:

<?php 
global $myOffset; 
global $wp_query;
$myOffset = 1;
$paged = intval(get_query_var('paged')) ? get_query_var('paged') : 1;
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(array(
	'offset' => $myOffset,
	'category__not_in' => array($GLOBALS['ex_asides'],7,84),
	'paged' => $paged,
	'showposts' => get_option('woo_other_entries'),
	)); ?>

example three:

<?php 
global $myOffset;
$myOffset = 1;
$wp_query = new WP_Query();
$wp_query->query(array(
	'offset' => $myOffset,
	'category__not_in' => array($GLOBALS['ex_asides'],7,84),
	'paged' => $paged,
	'showposts' => get_option('woo_other_entries'),
	)); ?>

And after those tries, I just can’t get more pages beyond the option’s that I choose, and can only pull an archive via the browse more link.

Any suggestions or anything?

Continue Reading

Tips & Tricks

Pulling custom fields from outside the loop

Published

on

In the last post “Creating a custom widget” I showed you how to create a custom widget. Well in this post I will show you how I used my custom widget to display all post with a certain custom field from outside the WordPress loop.

In the last post I used this tag:

<?php include(TEMPLATEPATH . '/includes/showcase.php'); ?>

Now I will show you what the file showcase.php has:

<ul>
<?php
global $wpdb;

$sql = "SELECT wposts.*
	FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
	WHERE wposts.ID = wpostmeta.post_id
	AND wpostmeta.meta_key = 'gallery-url'
	AND wposts.post_status = 'publish'
	AND wposts.post_type = 'post'
	ORDER BY wposts.post_date DESC LIMIT 8";

$pageposts = $wpdb->get_results($sql, OBJECT);
$output = $pre_HTML;

foreach ($pageposts as $post) : setup_postdata($post);  ?>

<li><a href="<?php echo get_post_meta($post->ID, "gallery-url", $single = true); ?>" title="Link to <?php the_title(); ?>">
<img src="<?php echo get_post_meta($post->ID, "image", $single = true); ?>" alt="<?php the_title(); ?>" /></a></li>

<?php endforeach; ?>

</ul>

That’s it! The most important item you may want to change for your own custom field is the line : AND wpostmeta.meta_key = 'gallery-url'. Where you would change the text in bold to match your own custom field value.

Update:

Check out Austin from PressedWords comment below.

With his great advise I was able to figure out why all my attempts to use the query_post weren’t working. it came down to this line of code: <?php echo get_post_meta($post->ID, "gallery-url", $single = true); ?>, that was what I had in my code, and the $post->ID is the reason my code would not echo or print the custom field’s value. Solution? replace $post->ID with get_the_ID(). HA, so simple.

Continue Reading

Random Search Terms

Title

Recent Posts: Fully Net Worth . com

Lil Uzi Vert Net Worth

Lil Uzi Vert Net Worth

Lil Uzi Vert Net Worth. Music is growing at a very rapid growth, such was for famous American rapper and songwriter, popularly known as Vert, but later changed to Lil Uzi Vert because fans described his rap flow very fast. His real name is Symere Woods, born on July 31st, 1994 in Philadelphia, Francisville. He […]

Justin Rose Net Worth

Justin Rose Net Worth

Who is Justin Rose? Justin Rose is an English golfer who plays mostly on the PGA Tour. Justin is known for winning the gold at men’s individual tournament and also being the runner up twice at the Masters’ Tournament in 2015 and 2017. Justin’ Early Life Justin was born on July 30, 1980, in Johannesburg, […]

Bad Bunny Net Worth: 5 Important Facts About Him

Bad Bunny Net Worth: 5 Important Facts About Him

Bad Bunny Net Worth: Benito Antonio Martinez Ocasio, known popularly by his stage name Bad Bunny, is a Latin trap singer/rapper, Songwriter from Puerto Rico. Born March 10th 1994, Which makes him a Pisces, he is known for his popular songs like Soy Peor. I Like It, Mia, and many others. Here are six facts […]

Marie Osmond Net Worth: 5 Interesting Facts You Should Know

Marie Osmond Net Worth: 5 Interesting Facts You Should Know

Marie Osmond is an American actress, singer, and designer. She gained international recognition in the 1970s after her success in country music. Marie is also known for hosting the television variety show “Donny & Marie” with her brother Donny Osmond. Here are five interesting facts about Marie Osmond 1. Marie Osmond net worth is estimated […]

Trending