<- Blog Home

Wordpress Theme

Creating custom wordpress theme

Creating a custom WordPress theme requires a combination of design and development skills. Here are the detailed steps to create a custom WordPress theme:

  • Plan Your Theme: Before you start coding, you need to plan your theme. Define its purpose, target audience, color scheme, typography, layout, and any other design elements that will be incorporated.

  • Set up a local development environment: You'll need a local environment to work on your theme. You can install WordPress using tools like XAMPP or WAMP.

  • Create a New Theme Folder: Create a new folder in the 'wp-content/themes/' directory with the name of your theme.

  • Create the necessary files: Your theme needs several essential files, including style.css, index.php, header.php, footer.php, and functions.php. Create these files in your new theme folder.

  • Add Theme Information: Open the style.css file and add your theme information. This includes the theme name, version, author, description, and other details.

  • Create the Header and Footer: Open header.php and footer.php files and create the markup for the header and footer sections.

  • Create the Index and Page Templates: Open the index.php file and create the main content of your website. Create additional page templates if necessary.

  • Create the Functions File: Open the functions.php file and add any additional functionality you want to include in your theme, like custom post types or widgets.

  • Style your theme: Open the style.css file and add the styles for your theme, including color schemes, typography, and layout.

  • Test your Theme: Test your theme on different devices and browsers to ensure that it looks good and functions properly.

  • Publish your Theme: When you are satisfied with your theme, you can publish it on the WordPress.org theme directory or sell it on marketplaces like ThemeForest.

Overall, creating a custom WordPress theme requires careful planning, design skills, and development skills. It's important to take your time and test your theme thoroughly before publishing it.

Main files in custom wordpress theme

Here are main files in csutom theme

  • index.php: The main template file for displaying home page.
  • style.css: The stylesheet for the theme, which contains the theme name, author, description, and other metadata.
  • functions.php: The file that contains all the PHP functions used in the theme.
  • header.php: The header section of the theme, which usually contains the site logo, navigation menu, and other site-wide elements.
  • footer.php: The footer section of the theme, which usually contains copyright information, social media links, and other site-wide elements.
  • sidebar.php: The sidebar section of the theme, which contains widgets and other elements that appear on the side of the main content.
  • single.php: The template for displaying a single post.
  • page.php: The template for displaying a single page.
  • archive.php: The template for displaying archives of posts.
  • search.php: The template for displaying search results.
  • 404.php: The template for displaying the "Not Found" error page.
  • category.php: The template for displaying a category archive.
  • tag.php: The template for displaying a tag archive.
  • comments.php: The template for displaying comments on posts and pages.
  • screenshot.png: A screenshot of the theme for display in the WordPress theme selection screen.

The functions.php file is a key file in a WordPress theme, as it contains PHP functions that can be used throughout the theme. In WordPress, a function is a block of code that performs a specific task. Functions are used throughout the core WordPress software and in WordPress themes and plugins to add new features and modify existing ones.

In a WordPress theme, the functions.php file is the main file where you can define custom functions to extend the functionality of your theme. The functions.php file is automatically loaded by WordPress when your theme is activated, and any custom functions defined in this file will be available for use throughout your theme.

Here are some examples of what you can do with functions in a WordPress theme:

  • Register custom post types and taxonomies.
  • Register custom image sizes for use in the theme.
  • Add or remove actions and filters.
  • Modify the output of WordPress functions using filters.
  • Enqueue stylesheets and scripts.
  • Define custom shortcodes for use in posts and pages.
  • Register custom widgets for use in the sidebar or other widget areas.

One of the great things about functions in WordPress is that they can be combined with actions and filters to modify the behavior of WordPress core functions and plugins. Actions and filters are hooks that allow you to modify the behavior of WordPress without editing the core files or modifying other plugins directly.

For example, you can use the add_action() function to execute a custom function when a specific action occurs in WordPress, such as when a post is saved or when the theme is initialized. You can also use the add_filter() function to modify the output of a WordPress function by passing the output through your own custom function.

Here are some common functions that might be included in a functions.php file:

Registering navigation menus:

function mytheme_register_menus() {
register_nav_menus( array(
'primary' => **( 'Primary Menu', 'mytheme' ),
'footer' => **( 'Footer Menu', 'mytheme' ),
) );
add_action( 'after_setup_theme', 'mytheme_register_menus' );

This function registers two navigation menus in the theme - one for the primary menu and one for the footer menu. These menus can then be added to the theme using the wp_nav_menu() function.

Enqueuing styles and scripts:

function mytheme_enqueue_assets() {
wp_enqueue_style( 'mytheme-style', get_stylesheet_uri() );
wp_enqueue_script( 'mytheme-script', get_template_directory_uri() . '/js/script.js', array(), '1.0', true );
add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_assets' );

This function enqueues the main stylesheet for the theme and a JavaScript file called script.js. These assets will be loaded on the front-end of the site.

Customizing the excerpt length:

function mytheme_custom_excerpt_length( $length ) {
return 20;
add_filter( 'excerpt_length', 'mytheme_custom_excerpt_length' );

This function filters the length of the excerpt displayed on archive pages. In this example, it's set to 20 words.

Adding theme support for post thumbnails:

function mytheme_setup() {
add_theme_support( 'post-thumbnails' );
add_action( 'after_setup_theme', 'mytheme_setup' );

This function adds support for post thumbnails, which can be added to posts and pages using the the_post_thumbnail() function.

Free wordpress hosting

There are many free WordPress hosting services available, but it's important to note that these services often come with certain limitations and restrictions, such as limited storage space, limited bandwidth, and limited features.

Here are some of the free WordPress hosting services that you can consider:

  • WordPress.com: WordPress.com is a free platform that lets you create a blog or website on their subdomain (e.g. yoursite.wordpress.com). It offers a limited number of themes and plugins, but it's a great option if you want a simple, no-frills website.

  • 000webhost: 000webhost is a free hosting service that offers WordPress hosting with no ads, no setup fees, and no hidden costs. They offer 300 MB of disk space, 3 GB of bandwidth, and a website builder. I created free wordpress site at https://sagarsalunke.000webhostapp.com/wp-admin/themes.php

  • AwardSpace: AwardSpace is a free hosting service that offers WordPress hosting with 1 GB of disk space, 5 GB of monthly traffic, and a website builder. They also offer a free subdomain.

  • InfinityFree: InfinityFree is a free hosting service that offers unlimited disk space, unlimited bandwidth, and a website builder. They offer a one-click WordPress installer and no forced ads.

  • ByetHost: ByetHost is a free hosting service that offers WordPress hosting with 1 GB of disk space, 50 GB of monthly traffic, and a website builder. They also offer a free subdomain.

It's important to note that free hosting services often have limited support, slower load times, and more downtime compared to paid hosting services. If you're serious about your website or blog, you may want to consider investing in a paid hosting service for better performance, reliability, and support.

Web development and Automation testing

solutions delivered!!