Include File Wordpress Theme

Add Tool

Include Any File Wordpress Theme


When we develop our WordPress theme we need to add various files in our theme. A WordPress theme is created by adding various part like header, footer, sidebar, style sheet, JavaScript, images etc. Here I have tried to present some WordPress snippets which will help you to Include Any File Wordpress theme. If you need another snippets you can ask me on comment. You should see WordPress Theme development cheat sheet at a glance.

Add Default style sheet

This snippets will add default style sheet in your WordPress theme. Only you need to create a css file as style.css and place the codes within <head> tag.

<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_url');?>" />

Add another style sheet from theme directory folder

You can create some style sheet like screen.css, layout.css, ie.css, comments.css for your WordPress theme. This snippets will add these style sheet in your WordPress theme. Place the codes within <head> tag.

<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('template_directory'); ?>/comments.css"  />

Here, comment.css is your CSS file name.

Add another style sheet from a folder

You can keep you CSS files in a separate folder in your theme directory. such as your-theme-name/css-folder-name This snippets will add these style sheet in your WordPress theme. Place the codes within <head> tag.

<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('template_directory'); ?>/css/screen.css"  />

Here, css is your folder name and screen is css file name.

Add style sheet using functions.php file

You can add your all Style sheet using functions.php file. Simply add the below snippets in your theme's functions.php file. I have just called some demo CSS file. You need call your CSS files.

<?php
function devtoolsplus_scripts_styles() {
 global $wp_styles;

//Loads our main stylesheet.
 wp_enqueue_style( 'devtoolsplus-style', get_stylesheet_uri() );

// Loads the Internet Explorer specific stylesheet.
 wp_enqueue_style( 'devtoolsplus-ie', get_template_directory_uri() . '/css/ie.css', array( 'devtoolsplus-style' ), '20121010' );
 $wp_styles->add_data( 'devtoolsplus-ie', 'conditional', 'lt IE 9' );
}
add_action( 'wp_enqueue_scripts', 'devtoolsplus_scripts_styles' );
?>

Add JavaScript in WordPress theme

This snippets will add JavaScript in your WordPress theme. Only you need to create js file and place the codes within <head> tag. If you weak in JavaScript you can use some redeemed JavaScript.

<?php 
wp_enqueue_script('jquery');
wp_enqueue_script('effects', get_stylesheet_directory_uri() .'/js/effects.js');
wp_enqueue_script('superfish', get_stylesheet_directory_uri() .'/js/superfish.js'); 
wp_enqueue_script('prettyphoto', get_stylesheet_directory_uri() .'/js/jquery.prettyPhoto.js'); 
?>

Add JavaScript using functions.php file

You can add your all JavaScript files using functions.php file. Simply add the below snippets in your theme's functions.php file. I have just called some demo JS file. You need call your JS files.

<?php
function devtoolsplus_scripts_styles() {
 global $wp_styles;
 wp_enqueue_script('effects', get_stylesheet_directory_uri() .'/js/effects.js');
 wp_enqueue_script('superfish', get_stylesheet_directory_uri() .'/js/superfish.js'); 
 wp_enqueue_script('prettyphoto', get_stylesheet_directory_uri() .'/js/jquery.prettyPhoto.js');
}
add_action( 'wp_enqueue_scripts', 'devtoolsplus_scripts_styles' );
?>

Include Image

<img src="<?php bloginfo('template_url'); ?>/images/demo.jpg" alt="devtoolsplus" />

Include PHP files

You can add or include any php file form theme directory folder by adding below snippets.

<?php include (TEMPLATEPATH . '/sidebar2.php'); ?>

Here, sidebar2.php is the php file name which I have included in my theme

Include PHP file form another folder

<?php include (TEMPLATEPATH . '/folder-name/sidebar2.php'); ?>

Another way of adding php file

<?php get_template_part('meta'); ?>

Here, meta is a php file name of my them folder.

Now collect this special WordPress code snippets which help you to Include File Wordpress Theme or follow WordPress cheat sheet for theme development


Tags: Include Any File Wordpress Theme, include php file in wordpress, Include File Wordpress Theme, WordPress Theme, Add JavaScript using functions.php file
Payza

About Masum Billah

Include Any File Wordpress Theme 1stWebSuite website seo tool is a free website ranking tool site provides a lot of on page and off page seo useful tools for you. On this site, we have a large number of website ranking tools


SIGN UP TO GET UPDATE TO YOUR INBOX




Discuss about: Include File Wordpress Theme


adf.ly