Thursday, October 3, 2013

Wordpress site quick start

These are some things that I find myself doing everytime I set up a new Wordpress page:

Direct access

If you want to enable wordpress to have direct access to upgrade or install plugins, put this at the end of wp-config.php:

 define('FS_METHOD', 'direct');  

Directories and permissions

Some additional directories are needed in /wp-content:

  • /uploads
  • /upgrade

Also don't forget to set the proper permissions to these and /plugins.

Theme

I created an "empty" theme which you can use to build yours (almost) from scratch. You can download it here:
https://docs.google.com/file/d/0ByJLxNUdJ5J-Y3NoOExBNUM2LVU/edit?usp=sharing
(Press ctrl + s to save the whole zip file)

Adding featured images to posts

Add this to the functions.php file of your theme:
 if ( function_exists( 'add_theme_support' ) ) {  
       add_theme_support( 'post-thumbnails' );  
 }  
(This is already in my theme by default.)

Quickly add a menu

First you have to add a menu location to header.php:

 <?php wp_nav_menu(array('theme_location'=>'header-menu')); ?>  

Then you can add the menu anywhere in your code with this:

 <?php wp_nav_menu('header-menu');?>  

Fix TinyMCE

Install the TinyMCE Advanced plugin and check the checkbox before "Stop removing the <p> and <br /> tags when saving and show them in the HTML editor"

You can also customize TinyMCE to your taste by adding control elements.

Creating page templates

If you want to create a new template for your pages, simply create a new php file in the theme directory (for example: page-people.php) and put the following code in it:

 <?php /* Template Name: Modify this to the template name */ ?>  
 <?php get_header(); ?>  
 Loerm ipsum... insert your code here  
 <?php get_footer(); ?>  

After saving, you will be able to choose it while editing pages.