Connect with us

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
3 Comments

3 Comments

  1. Pingback: WordPress links week 4 - 2009 | WPStart.org - WordPress themes, plugins and news

  2. Daniel

    May 23, 2009 at 7:04 am

    Cheers. Very useful. 🙂

    I don’t suppose could help me with adding a little extra to this. I want to put “…” at the end if the amount of chars in the title exceeds the cut off point.

    • Austin

      May 25, 2009 at 2:45 pm

      Hmm, not really sure how to print that if, and only if characters are less than whats printed. May want to chack out pnp.net

You must be logged in to post a comment Login

Leave a Reply

Tips & Tricks

How to: Open external links in a new window

Published

on

Over the weekend, I attended WordCamp Denver, and I was asked by John Hawkins how to force links to open in a new tab with out editing the source code. So, today lets learn a simple jQuery trick to open all external links in your site in a new tab or window. We are going to make sure you have jQuery active on your site, you can do this easily in WordPress, since it’s bundled with the latest installations. Use this code in your header: <?php wp_enqueue_script('jquery'); ?> then, below the wp_head add the following:

<script type="text/javacript">
var $j = jQuery.noConflict();

$j(document).ready(function() {
//external attribute
    $j("a:not([@href*=http://YOURSITE.com/])").not("[href^=#]")
        .addClass("external")
        .attr({ target: "_blank" });
    }
);
</script>

That’s it, just make sure you change the http://YOURSITE.com to your website.

Update

If you like you can remove the var $j = and replace all $j with simply just $

 

Continue Reading

Themes

Fixing plugins not compatible with hybrid 0.4.2

Published

on

Hey everyone, as you may have noticed I have a running on the site. While everything almost everything moved over smoothly, there was an issue with how my parent theme striped text in typography. This caused some plugins, like cformsII to not be allowed to print to the screen. Justin had helped to find a fix to filter the hybrid_typography function.

Originally this function filtered out and changed some text that would not validate as XHTML. This had to be removed by running a new function in the child theme’s function.php file.

add_action('init', 'remove_typography');

function remove_typography() {
	remove_filter('the_content', 'hybrid_typography', 11);
}
Continue Reading

Plugins

Add the twittar plugin for WordPress w/ comment threading

Published

on

I talked about the Twittar plugin in a previous post. But learned that the read me text file was only useful for installing the necessary php code into WordPress themes that don’t have comment threading enabled.

Since most new themes past version 2.7, pull the comments section from functions.php file, that is where you have to edit the avatars in order to show the twittar settings.

First open you functions.php, and look for a line of code that says:

function custom_comment()

This is where your new comments are pulled from when you have the threaded comments enabled.

Now just find <?php echo get_avatar( $comment, $args['avatar_size'] ); ?> & replace with <?php twittar(70, "", "", "avatar avatar-70 photo", 1, "R"); ?>. Keep in mind that you will need to edit the Twittar setting to fit your site.

Continue Reading

Random Search Terms

Title

Recent Posts: Fully Net Worth . com

Alexandra Grant Net Worth: How Rich is Keanu Reeves’ Girlfriend?

Alexandra Grant Net Worth: How Rich is Keanu Reeves’ Girlfriend?

Alexandra Grant is an American art designer who examines language and written texts through painting, drawing, and sculpture. She is recently in the news after she was spotted holding hands with famous actress Keanu Reeves. Alexandra Grant net worth currently is under review Grant was born in 1973, in Fairview Park, Ohio. Her parents divorced […]

Pete Buttigieg Net Worth: 5 Facts You Should Know

Pete Buttigieg Net Worth: 5 Facts You Should Know

Pete Buttigieg is the mayor of South Bend, Indiana. He is also an American war veteran and a former consultant. In the recent days, Buttigieg has been growing his name with him announcing candidacy for the Presidential election in 2020. Then President Obama called him as one of four Democrats who represented the future of […]

Yandy Smith Net Worth

Yandy Smith Net Worth

Yandy Smith Net Worth. The American celeb Yandy Smith has a net value of $15 million. She is a reality TV star and music producer. Yandy started her professional career working in the entertainment industry. She started working as an executive assistant in a company called Violator Management. Some of her clients include high-profile musicians […]

Jasmine Luv Net Worth: How Rich is the YouTube star?

Jasmine Luv Net Worth: How Rich is the YouTube star?

Jasmine Luv is an American Youtuber who is known for her comedic videos which are very relatable to the fans. This has helped her to build a fan following on Instagram of over 1.3 million and is also working on a Youtube Channel that has already crossed 110k subscribers. As of 2019, Jasmine Luv net […]

Trending