Dynamic Copyright

I hate hate hate sites that don’t update there copyright. I know if you don’t use some sort of template system it can be hard to shift through all of your pages to do this. So make your website with WordPress or hire someone to do it for you, I am busy I can’t help you.

Anyways in your footer now you should change it to:

Copyright&copy; 1989 – <?php print date(“Y”); ?>. All Rights Reserved.<br/>

Copyright&copy; 1989 – <?php print date(“Y”); ?>. All Rights Reserved.

So now with php the year gets generated dynamically, every year, So you don’t have to worry about it ever again.

Posted in PHP | Tagged , , | Leave a comment

Removing Dotted Lines Around Links

This is a css tip that I often overlook. I am not a great css designer, it kind of fell into my lap one day. I got the opportunity to take a job offer from suicide girls. They were looking for some web designer slash programmer slash css guru slash computer tech support person. I fall into all of those categories but css. But they really wanted a local css guru, and I was local. But the problem was I had no idea about css at all. So they gave me a problem, I had to make there future site ie7 and below compatible. I said that I could do it in a few hours, so I had to figure out WTF css was real quick. Long story short, I made there page compliant, but I didn’t really want the job.

dotted-lines-around-linksThis isn’t a story, but how I do navigation bars. I either use an ul or i just make the navigation a div and put some classes in there. I think google likes it that way if there is text in there, and then I push all the text off of the screen and replace it with a pretty image. Well because the text is off the screen the link still has dotted lines around it and they go off the screen. Not nice looking when you click on links. So to get rid of this you need to add:


a
{
outline: none;
}

to your style sheet.

Posted in CSS | Tagged , , | Leave a comment

Custom Page Templates Not Showing Up In WordPress

I litterally created a new template for an internal project today and it wasn’t showing up on the template drop down menu. It was freaking me out, I spent a good five minutes trouble shooting it by: Making a new template, making sure that it had the right file permissions, renaming it, renaming the file. And then I googled the problem and came up with this post.

So if this happens to you, or me again:
1. Activate a different theme (I just activated the default)
2. Reactivate your desired theme
3. Go to Manage > Pages
4. And you should now see the Page Template

What I had done to get this not working, is I renamed the theme folder name and it wasn’t really activated in the WordPress dashboard for some reason. But it was still working on the site.

Posted in Wordpress | Tagged , , , , , | Leave a comment

Custom Templates

Creating custom templates for pages is what makes wordpress extremely valuable. That is wordpress’s hidden secret that makes it so important for a blogging and CMS platform. I use wordpress custom templates in every wordpress site that I make.

To create a custom template first you have to create a php file and I tend to normally name it something that is similar to the page’s name so I don’t get confused later on. So as an example if i was going to make a contact me page, I would create a file and name it contactme.php and in that file I would add this in the file:


<?php
/*
Template Name: Contact Me
*/
?>

Then you add what you want in there, for now we will just add the header, sidebar, and footer include and a little bit of customizing.

contactmeSo now you have the file and you upload it to the current activated theme directory. After you have done this you need to go to add new page in the wordpress dashboard. And on the right hand side under attributes. You need to click on where it says default template and change it to Contact Me. That way the contact me page will use that template. As of right now anything that you put into this contact me page will not show up on the template because we have not included any page information to include. That will be for a next lesson.

Download Contact Me Source Code (You will have to rename the extension from .phps to .php)

Posted in Wordpress | Tagged , , | Leave a comment

A Good Webhost

If you do use wordpress and are hosting websites, It is even better to make sure that your web host is up and running also and will work with what you are doing. I have found that dreamhost is a good web hosting company.

I literally purchased this domain and got this website going in less than three minutes. It took no time at all and I had no hangups. If it took any longer I would have given up and moved onto something else.

There are three ways that you can go about setting up a wordpress install on Dreamhost. I went with the custom way as it is the fastest way and it doesn’t install any crap. But you can do the one click install and it should work fine for you.

Anyways, if you are looking for a good host dreamhost is a good hosting solution.

Please use this link if you signup, I will get a referral which pays for this hosting. Thank you.

Posted in Wordpress | Tagged | Leave a comment

Get the First Image From Post

I had wanted to get the first image from a post since I started using wordpress. Problem was, I wasn’t smart enough to understand how to do it. Or how to even think about the ways to go around doing it. I was using the Post Thumb plugin but it wasn’t ever getting updated and it was getting a little bloated with features. I just wanted the ability to get the first image from a post. So finally I stumbled upon this thread, Where the solution was laid out right in front of me.

So, you need to edit or create the functions.php file in your theme directory. And add:

function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('//i', $post->post_content, $matches);
$first_img = $matches [1] [0];
// no image found display default image instead
if(empty($first_img)){
// $first_img = "/image/omg.png";
}
return $first_img;
}

and you call it in your template files in between the loop with:

<?php echo catch_that_image()?>

Next post I will show how to resize the post dynamically with TimThumb.

You can see a working example of this in use at: Marissa Textor and Obey Giant.

Posted in Wordpress | Tagged , , | 2 Comments

Dyanmic Image Resizing

I use timthumb for dynamic image resizing. It works on most webhosts and requires little to no setting up. All you have to do is upload the file to your website and link to it like so:

<img src="//timthumb.php?src=/images/whatever.jpg&amp;h=150&amp;w=150&amp;zc=1" alt="" />

And you can adjust the height, the width and the quality of the image resized. The above code will make the image 150 pixles wide and 150 pixels width with no cropping of the image.

If you wanted the image to be resized to anything else you just change those settings. You can see timthumb in use heavily at My Name is Casey and Studio Number One.

Posted in PHP | Tagged , , , | Leave a comment

After WordPress Install

The first thing I do after a wordpress install:

1. I change the permalinks structure to “/%category%/%postname%/”. I don’t use category pages, I make pages in place of the categories. I don’t like how it looks when you use normal category templates, So I create custom queries on the pages that call the category.

2. I change where images are uploaded. I like it when images are in the images folder. Just another cosmetic issue for me.

3. This is the first time where I did not do this. But then I create a theme in the theme directory and start working on making the new theme. I am not a designer, so this time I went into Add New Themes and Ii found a theme that I liked.

4. Next I usually add the functions that I use in almost every theme that I make into the functions.php file in the theme directory. I add get_the_image which gets the first image from a post and returns the url. I then add the content shortener that shortens the content to so many letters.

5. I get and install TimThumb, when the website works with a lot of images and resizing of images I use timthumb to resize the images o the fly for me. Bonus: Has built in cache.

6. I install these plugins: wp-cache, wordpress stats, sitemap generator and akismet.

7. I then Edit the about page as it is the most important part of a website and then delete the hello world. But I am going to be keeping the Hello World on this one so it reminds me to post some more.

8. Then I make my first post and hope for the best!

Welcome to WordPress Tips, My new website where I post tips and tricks for wordpress that I do in my daily life of working with wordpress. I just hope that it will help others and I am going to use this so I am able to go back and see how I did things.

Posted in Wordpress | Tagged , , | Leave a comment

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

Posted in Site | 1 Comment