10 Useful Ways To Help You Modify Your WordPress Theme

 10 Useful Ways To Help You Change Your WordPress ThemeWordPress is a CMS platform that is by far the fastest growing one in today’s web design industry. A big part of the action taking place in the WordPress community is mainly driven by the market of WordPress themes.

A wide variety of free and commercial themes is just one of the things that make WordPress so attractive to use. But the subject is often just a starting point to further adjustments. Web developers and website owners prefer to start with a theme, and then to further adapt to their needs until it reaches the desired look or until they meet the desires of a client.

Many topics, especially the commercial ones, come in a package with a page featuring clear options related to this subject, which allows the configuration of most aspects. It is best to look at all the options that exist before “diving in” into the code. In other words, each topic is different from other ones, and sometimes you have to put in more effort and enter the code in order to fully adapt to your needs.

The following are things that owners of websites prefer to change and a how-to tutorial on implementing and using these changes! This article is written assuming you have at least some basic knowledge of web design, editing code, and that you are familiar with the WordPress platform.

A word of advice before you go into the details: It is often a good idea to make all modifications on “The child theme (Child Theme)” instead of on “Parent themes (Parent Theme)”. The advantage here is that when the author updates his themes you can easily update yours without losing the modifications you have made. See WordPress.org Codex for more information on “Child theme”.

Editing the CSS Themes

 10 Useful Ways To Help You Change Your WordPress ThemeIf you want to change the color, font, layout, background, spacing, and other visual elements, it is best to start with editing the CSS. In most cases the styles used by your theme are found in a file named style.css. This file is always in the theme, since this file defines the themes in WordPress admin section. Sometimes there are some additional styles, which can be located in subfolders.

The best way to find a style that you should change, as well as the location and style of the theme files, is to install the tool for web development, such as for example FireBug. This is an extension for Firefox that lets you view CSS on the fly and quickly locate the style and line that needs to change. If you do not use FireBug, it’s about time you started.

Displaying a Section of a Post or All of the Content

Sometimes, by default, your theme displays the full content of posts on the home page. Let’s say that you would prefer to view a short paragraph, just to attract the attention of readers to click on and view the entire text. Or maybe vice versa – the theme shows excerpts, but you’d prefer to display them all.

Here are two tags that should be replaced:

This tag displays the entire contents of posts:

<? php the_content (); ?>

For more information on this tag click here.

This tag displays the section of fasting (when editing a post, it is the text you type into the text box just below the text box for the contents of the entire subject):

<? php the_excerpt (); ?>

If no exceptions are not rigged will automatically show the first few sentences of your post.

For more information on this tag click here.

Create Your Own Template for a Specific Page

It happens that it is necessary to create a specific site that needs to have its own special layout – something different from the others. You would like some flexibility in the HTML source, but that the changes you make do not affect other parties that already exist on your site.

WordPress seems to create unique templates and assigning them to a particular page tends to be fairly easy. Here’s how:

  • Make a copy of the page.php file located in your topic. This is the file that WordPress uses to display pages.
  • Rename the copy that you want. In this example we’ll call it, prices.php (we’ll create a unique way to display the price).
  • At the top of the page, add this section of code:

<? Php / * Template Name: Prices * / ?>

  • Modify the HTML code and CSS for this page the way you want it
  • Create a page within WordPress with the name “Price”. Using the drop down menu to select templates, select “Prices”.
  • Save the page. There will now be a page displayed using templates that you created.

Make a Loop: Turn Categories On/Off

Suppose you want to display posts from all categories except for one. This is a very common request for various reasons. One example would be to have prominent posts in the form of a slider on the home page that displays posts from the category of “Highlights”. You would want to display posts below the slider but in such a way there are no posts from the category “Highlights” included, because they would be doubled on the page. Here’s how you do it:

Add this line before the loop:

<? Php query_posts ('cat = -8'); ?>

This will turn off the display of all the posts that are in the category with ID 8. Therefore it is necessary for you to know the ID of the category you want to turn off. You can see it in the admin section of the site for administration category.

You might want to do the opposite and only display posts from a particular categories. Simple! Remove the “-” before the ID of your categories:

<? Php query_posts ('cat = 8'); ?>

More information on the Loop and Query Posts.

Navigating the Easy Way

10 Useful Ways To Help You Modify Your WordPress ThemeMany themes displays all of your pages on top of the site with the help of the dropdown menu or hierarchical navigation. But let’s say you want to avoid some aspects of navigation. Sometimes you will have pages that need not be immediately exposed, such as, for example, “Terms of use”.

Here are easier ways to turn off a page from the display menu:

Find the code that displays a list of pages:

<? Php wp_list_pages (); ?>

Change it into:

<? Php wp_list_pages ('exclude = 5'); ?>

This way you “command” WordPress: “List me all the pages I have made except the one that has the ID 5”. Of course you do not need to say it out loud, this line of code is sufficient enough :). As in the previous case with the categories, here too you need to know the ID of the page you want to turn off.

More information: WP List Pages

Turning Menu Management On in WordPress 3.0 and Above

Do you want to have complete control over navigation on your site, such as, for example, fixing your desired sequence, on/off page, categories, and external links? Who wouldn’t want it? WordPress 3.0 comes with a new cool feature called “Menus”, which gives you this flexibility. However, this option can be used only if your theme supports the same.

Here’s how to change the traditional navigation using wp_list_pages (), into a new one that can be controlled from the admin work.

NOTE: You must have WordPress 3.0+.

First, you must enable this feature by adding the following line of code in the functions.php file:

<? Php add_theme_support ('nav-menus'); ?>

Then add your menu in the theme, somewhere in the header.php file:

<? Php wp_nav_menu (); ?>

Of course, you’ll need to create your own menu by going to Appearance> Menus. More information: WP Nav Menu

Create a Simple IF

Sometimes you would like for some of the content to change depending on the page the user has before him. For example, when the user looks at the ‘prices’, you want to have a message “The prices for every budget,” on the side but on all other pages you would want to display other messages to the one we’ve already mentioned. For instance, you’d want a “High-quality products, reliable service” message displayed.

Here’s how to install it using IF:

<? Php if (is_page ('Prices')) {?>

Pricing for every budget!

<? Php} else {?>

High-quality products, reliable service!

<? Php}?>

More information: Conditional Tags

Post Thumbnails

10 Useful Ways To Help You Modify Your WordPress ThemeWordPress 2.9 has introduced a nice feature called “Post Thumbnails”. As the name suggests, allows you to set the thumbnail picture to your post without having to specify a custom field or to insert a picture in the content of the post.

 

NOTE: In WordPress 3.0, this option has been renamed to “Featured Image”, but the functionality remains the same.

Post Thumbnails is a useful option for your posts, or if you use WordPress posts as your portfolio. There are many other situations where thumbnails come into play. Here’s how to include this option in your theme:

As with the menus option, Post Thumbnails must be included in the topic. Add this line of code in the functions.php file:

<? Php add_theme_support ('post-thumbnails'); ?>

Then, enter the post thumbnail image within a loop, using the following tag:

<? Php the_post_thumbnail (); ?>

You might want to tweak the layout using CSS. You can also add the possibility of different sizes and the option of cutting files. Check out this tutorial on the option Post Thumbnails for more information.

Add Something to the Near Post

In some situations you may want to add something to the end of each post – something constant, say a message promoting your services, a link to signing up for a newsletter, an advertisement, etc.

The file you want to edit is the single.php. This is the template that displays articles on the blog. Open the file and find a good place to add the desired content. A good place is usually below the article or just above the comments:

<? Php the_content (); ?>

Your extra content …

<? Php comments_template (); ?>

Your theme could have the additional tags or whatever but this will point you in the right direction.

Adding Google Analytics Code

Everyone wants to know how many people come to the site that they own. Google Analytics is the most popular tool for tracking visits to your site. Placing Google Analytics is very easy. When you create your free account Google will display a few lines of code that should settle on your site.

10 Useful Ways To Help You Modify Your WordPress Theme

Until recently, using traditional analytics code that is placed in the bottom of the page i.e. before the closing of body part, that is before the tag. This city is located in the footer.php file.

Now, the new so-called Asynchronous code is used and added before closing the head part, i.e. before the tag. A new way of monitoring visits is far more efficient and accurate.

Tags:

No comments yet.

Submit Comment