Tips & Tricks
Display custom url if comment authors url is blank
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 } ?>
Plugins
How to: Creating an Archive page
Many weblog sites these days have some form of an archive page. In WordPress it might be the built in auto generation of permalinks by: /Month/
and /date/
.
But in some blog’s, for instance this one here (as I said in a previous post) you can’t get the post to paginate or link to http://youblog.com/page/2
if you have nice permalinks active or http://youblog.com/?paged=2
.
By any means, In this theme I have to have an archive link at the bottom. So..
Archive WordPress Plugins
There are many plugins which allows you to automatically create an archive page. The good thing is that you’ll (almost) have nothing to do, and the bad thing is that you may not be able to customize your archives much.
On this blog I have decided to use Clean Archives Reloaded by Viper007Bond. Which you can now see active in my Archive’s page.
If you want to use a plugin, here is a small list:
And of coarse you can always..
..do it your self!
First you would have to create a template file by writing this:
<?php /* Template Name: Archive page */ //please add you necessary code here //ie. your hooks and html code ?> <ol id="archive"> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array( 'showposts' => 100, 'offset' => 10, 'order' =>'DES', 'paged' => $paged, )); $wp_query->is_archive = true; $wp_query->is_home = false; if( have_posts() ) : while( have_posts() ) : the_post(); ?> <li><a href="<?php the_permalink() ?>"><?php $tit = the_title('','',FALSE); echo substr($tit, 0, 25); ?>...</a> - Posted on <?php the_time('j F Y') ?> - Comments (<?php echo $post->comment_count ?>)</li> <?php endwhile; endif; ?> </ol> ?>
You may notice this code:
<?php $tit = the_title('','',FALSE); echo substr($tit, 0, 25); ?>
from a previous post!
Once saved and pasted it to your archives.php
or template-archives.php
file, upload it on your wp-content/themes/yourtheme/
directory.
Then, in WordPress dashboard, create a new page, name it “Archives” (or whatever you want) and select Archive page as your page template.
enjoy!
Tips & Tricks
Limit the characters that display on the_title
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.
Tips & Tricks
Can′t add pagination on WooThemes Thick Theme
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?
-
Tips & Tricks3 months ago
WordPress Security Hacks
-
Pages2 days ago
Write For Us – Guest Post
-
Showcase2 weeks ago
StylizedWeb.com
-
News5 months ago
How to: Show/Hide any div box with jQuery in WordPress
-
Tips & Tricks4 months ago
Remove the title attribute using jQuery
-
Tips & Tricks2 months ago
How to: show/hide a widget in WordPress with jQuery
-
Plugins2 months ago
Top Membership plugins
-
Tips & Tricks2 weeks ago
Limit the characters that display on the_title
Pingback: Weekend Links - Jan 16, 2009 | OMNINOGGIN
Pingback: Weekend Roundup #32 » JaypeeOnline // Blogging News & Reviews
arcade games
March 11, 2009 at 3:13 pm
very nice idea, it could be an advertising slot.