Theme Files
You can get theme menu from Admin > Theme
Theme Files:
A Theme of Borno minimum need below's five file. That's are :-
- index.php (Main Page)
- doc.php (Document Page)
- single.php (Single Content Page)
- 404.php (Error Page)
- style.css (Style File , You can register and access your theme name from here)
Another's Are
- category.php
- profile.php
- search.php
- functions.php (You can do all function job of a theme from here)
- comment.php
You can also add
- header.php
- sidebar.php
- footer.php
Header.php
You can use the following example code on header.php
How to display page title ?
You can display page title by the_title() function
Ex :
<title> <?php echo $title ; ?></title>
You must give this meta on header
<meta charset="UTF-8">
You can include your theme style.css by this way
Ex:
<link rel='stylesheet' href="<?php echo theme_directory() ;?>/style.css">
You must add <?php header_view() ; ?> between <head> and </head>
Index.php
You can display the main page content by this way
<?php if(have_post()):while($content = the_nav() ): ?>
<h2><?php echo the_post_link($content['id']);?></h2>
<?php echo $content['content']; //displaying the content from the database?>
<?php endwhile;else :?>
Not Found . Error Msg
<?php endif;?>
<ul class="pager">
<li class="previous">
<?php previous_page_link() ;?>
</li>
<li class="next">
<?php next_page_link();?>
</li>
</ul>
You can also use this code on
- category.php
- profile.php
- search.php
Footer.php
You can use the following example code on footer.php
You can include your theme javascript file by this way
Ex:
<script src="<?php echo theme_directory() ;?>/yourjsfilename.js"></script>
You must add <?php footer_view() ; ?> before </body> tag
Single.php
A example single.php file
Note : $post_id is always generated automaticly
<h2><?php echo the_post_link($post_id); //title ?></h2>
<?php
/*
* Meta
*/
echo ' Write by ';
echo the_user_link(the_post_user('id'));
echo ' , ';
echo the_post_cat($post_id);
echo date_of_post($post_id,'d-m-y');
echo count_the_post_comment($post_id);
echo post_visit_count($post_id);
?>
<?php
echo post_content($post_id,) ;//post content
echo '<br>';
echo content_edit_link($post_id,get_the_option('site_address'),loginuserinfo('id'));
?>
<?php
include('comments.php');
?>
Doc.php
A example doc.php
<a href="<?Php echo doc_link($_GET['doc']); ?>"><?php echo get_the_doc_page($_GET['doc'],'title'); ?></a>
<?php echo get_the_doc_page($_GET['doc'],'content'); ?>
sidebar.php
A sample sidebar.php
<?php
if( check_sidebar_widget('Left') ){
display_sidebar('Left' ,'widget nav','current_page_item' );
}
?>
comment.php
A sample comment.php
<?php
/*
*
* li_comment($post_id);
* You can get the all comment list of any post .
*
*
*
*
*/
li_comment($post_id);
/*
*
*
*
$query = comment_query(3);
while($row = mysql_fetch_array($query)){
echo $row['id'].'<br>';
}
*
*
*/
/*
*
*
*
*
# add_comment(1,1,'test comment',1);
# add_comment($user_id,$post_id,$content,$approved)
# You can add comment by this function .
*
*
*
*
*/
/*
*
*
*
* Check comment permission of any post
* check user login or not
* check if user can add comment
* display the comment form
*
*
/*
*
* comment_form();
* comment form
*
if(get_the_post($_GET['p'],'comment_permission')=='true'){
if(user_logged_in()){
if(user_can('add_comment')){
comment_form();
}
else{
echo 'You cant not add comment';
}
}
else{
echo 'You must be logged in to add comment in this content';
}
}
else{
echo 'You can not add comment in this post';
}
*
*
*
*
*
*
*
*/
if(get_the_post($_GET['p'],'comment_permission')=='true'){
if(user_logged_in()){
if(user_can('add_comment')){
comment_form();
}
else{
echo 'You cant not add comment';
}
}
else{
echo 'You must be logged in to add comment in this content';
}
}
else{
echo 'You can not add comment in this post';
}
Style.css
You can register your theme name , detail and author name from style.css
A sample style.css file
/*
Theme Name : Test
Author : John Ex.
Detail : This is an paid theme
*/
/* custom style */
body{
background:red;
}
Functions.php
You can add custom functions, rules in you functions.php
<?php
add_sidebar("left")//the function add a left sidebar
No comments:
Post a Comment