Categories
PHP Wordpress

Worpress: useful codex commands

<?php get_cat_name( $cat_id ) ?> Get the category name if you have the id of it

<?php get_category_link( $category_id ); ?> Get the category permalink

Categories
PHP Wordpress

WordPress: produce new templates that can be used for new pages

Put them on your Themes directory, any php file that is there and includes the following header will be included in the drop-down menu for templates to choose from while creating a page:

<?php/*Template Name: Custom Feed*/

Categories
JavaScript PHP Wordpress

WordPress: Adding the version of jquery that comes with the installation

wp_enqueue_script('jquery');
Categories
SEO Web optimization Wordpress

WordPress: bringing a site from the ground up

These are the must haves, if you want your blog to be successful, and problem free

1) Active your Akismet plugin

2) Install Google Analitycs for WordPress from the get go.

3) Ditto for SEO.  Here’s a good plugin: http://wordpress.org/extend/plugins/seo-ultimate/

4) Subscribe to the following free auto-listing and update services (under “Settings / Writting”):

http://codex.wordpress.org/Update_Services

This usually ping the search engines to start indexing your site, but don’t count on it for that.

5) Generate a google site map, to let google know about your pages. Plugin: google XML Sitemaps http://wordpress.org/extend/plugins/google-sitemap-generator/

Categories
PHP Wordpress

Adding actions to wordpress based on events

add_action($tag, $function_to_add, $priority, $accepted_args);
add_filter($tag, $function_to_add, $priority, $accepted_args);

The $tag parameter is where you specify the hook you want to add to; $function_to_add is the name of your function. The next two are optional, but worth knowing about: $priority is used to determine the order in which your action ought to occur, relative to other actions that might be happening on the same hook—larger numbers happen later. $accepted_args

And to remove them (notice you have to do this indirectly):

function remove_some_filter() {
  remove_filter(tag, function, priority, args);
}

add_action('init', 'remove_some_filter')


Example:

add_action('wp_head', 'wicked_favicon')

This runs everytime the page head is constructed, you can have the specific function inside functions.php:

function wicked_favicon() {
  echo '<link rel="shortcut icon" href="' 
      . get_bloginfo('stylesheet_directory') 
      . '/images/favicon.ico"/>';
}

Categories
PHP Wordpress

Basic wordpress functions

All functions you want to overwrite, you can put it inside functions.php on your child theme, regarding pre-established functions:

  • get_header grabs header.php

  • get_footer grabs footer.php

  • get_sidebar grabs sidebar.php

  • get_searchform grabs searchform.php—if this is missing, WordPress simply renders a default search form

  • comments_template grabs comments.php

  • get_header('custom'), for example, will grab a file called header-custom.php
  • get_template_part('partname'), which grabs a template called partname.php
  • include(STYLESHEETPATH . ‘/extrastuff/somefile.php’); use the path to your stylesheets to get to a file, you can also use TEMPLATEPATH

Categories
Wordpress

WordPress: choosing and modifying a theme

1) Download thematic (as the parent theme)
2) Create a child theme folder for the new site, and activate it using wordpress admin screen
3) Choose the basic layout you need, by modifying this line:
@import url(‘../thematic/library/layouts/2c-r-fixed.css’);
You can also create your own layout at this point if you feel like it. Same with typography or other things.
4) You can also modify the default main css to your site by creating a local copy on your child theme:
@import url(‘newstyles.css’);
5) Modify the templates and functions from the parent directory directly at the child’s folder, that way
you can always update the parent theme without affecting the child

Correction: 20/11 newest wordpress theme is set to be HTML5 already. Use that instead.