Created
August 3, 2016 05:45
-
-
Save TANVIRFAZLEY/41a5feea22476cad6feac02a5e70c078 to your computer and use it in GitHub Desktop.
wordpress theme development basic file incclude
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WP Theme Development-1 (Create PHP Files) | |
header.php | |
================================== | |
< ?php bloginfo('name'); ?> = ব্লগের নাম আনার জন্য | |
< ?php echo get_template_directory_uri(); ?> = ডাইনামিক থিম ডাইরেক্টরী | |
< ?php bloginfo('stylesheet_url'); ?> = ডাইনামিক স্টাইল শীট | |
< ?php wp_head(); ?> = হেডারের ক্রীপ্ট পাওয়ার জন্য | |
index.php | |
================================== | |
< ?php get_header(); ?> = header.php ফাইল কল করার জন্য | |
< ?php get_footer(); ?> = footer.php ফাইল কল করার জন্য | |
< ?php get_sidebar(); ?> = sidebar.php ফাইল কল করার জন্য | |
< ?php get_template_part('file_name'); ?> = যে কোন ফাইল কল করার জন্য | |
functions.php | |
================================== | |
সাইডবার রেজিস্ট্রার করার জন্য | |
function rasel_widget_areas() { | |
register_sidebar( array( | |
'name' => __( 'Left Menu', 'rasel' ), | |
'id' => 'left_sidebar', | |
'before_widget' => ' | |
', | |
'after_widget' => ' | |
', | |
'before_title' => ' | |
', | |
'after_title' => '', | |
) ); | |
} | |
add_action('widgets_init', | |
'rasel_widget_areas'); | |
Sidebar.php | |
=================================== | |
সাইডবার কল করার জন্য | |
= এখানে left_sidebar হল সাইড বারের আইডি। | |
Post Query in index.php | |
===================================== | |
<?php if(have_posts()) : ?> | |
<?php while (have_posts()) : the_post(); ?> | |
<!-- Your Post Query here --> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
Pagination in index.php | |
===================================== | |
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older | |
posts') ); ?></div><div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span | |
class="meta-nav">→</span>') ); ?></div> | |
Post Information Query in index.php | |
===================================== | |
<?php the_title(); ?> = পোস্টের শিরোনাম আনার জন্য | |
<?php the_permalink(); ?> = পোস্টের লিংক আনার জন্য | |
<?php the_time('M d, Y') ?> = পোস্টের সময় আনার জন্য | |
<?php the_excerpt(); ?> = পোস্টের সারাংশ আনার জন্য | |
<?php the_content(); ?> = পোস্টের পুরো অংশ আনার জন্য | |
<?php the_category(', '); ?> = পোস্টের বিভাগ আনার জন্য | |
<?php comments_popup_link('No Comment', '1 Comment', '% Comments'); ?> = পোস্টে কমেন্ট সংখ্যা ও তার লিংক আনার জন্য | |
single.php | |
===================================== | |
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?> | |
<h2><?php the_title(); ?></h2> | |
<?php the_content(); ?> | |
<?php comments_template( '', true ); ?> | |
<?php endwhile; ?> | |
<?php else : ?> | |
<h3><?php _e('404 Error: Not Found'); ?></h3> | |
<?php endif; ?> | |
archive.php | |
for Archive & Archive Post List | |
===================================== | |
<h1> | |
<?php if (have_posts()) : ?> | |
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> | |
<?php /* If this is a category archive */ if (is_category()) { ?> | |
<?php _e('Archive for the'); ?> '<?php echo single_cat_title(); ?>' <?php _e('Category'); ?> | |
<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?> | |
<?php _e('Archive for the'); ?> <?php single_tag_title(); ?> Tag | |
<?php /* If this is a daily archive */ } elseif (is_day()) { ?> | |
<?php _e('Archive for'); ?> <?php the_time('F jS, Y'); ?> | |
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?> | |
<?php _e('Archive for'); ?> <?php the_time('F, Y'); ?> | |
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?> | |
<?php _e('Archive for'); ?> <?php the_time('Y'); ?> | |
<?php /* If this is a search */ } elseif (is_search()) { ?> | |
<?php _e('Search Results'); ?> | |
<?php /* If this is an author archive */ } elseif (is_author()) { ?> | |
<?php _e('Author Archive'); ?> | |
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && ! | |
empty($_GET['paged'])) { ?> | |
<?php _e('Blog Archives'); ?> | |
<?php } ?> | |
</h1> | |
For archive post query | |
<?php get_template_part( 'post-excerpt' ); // Post Excerpt (post-excerpt.php) ?> | |
If no post in archive or 404 | |
<?php else : ?> | |
<h3><?php _e('404 Error: Not Found'); ?></h3> | |
<?php endif; ?> | |
404.php | |
===================================== | |
<h2>404 Error: Not Found</h2> | |
<p>Sorry, but the page you are trying to reach is unavailable or does not exist.</p> | |
/*===================== comments =====================*/ | |
.comments {margin: 10px 0;} | |
.comments h3 {margin:50px 0 30px 0;font-size:24px;} | |
ol.commentlist { list-style:none; margin:0 0 1em; padding:0; text-indent:0; } | |
ol.commentlist li { } | |
ol.commentlist li.alt { } | |
ol.commentlist li.bypostauthor {} | |
ol.commentlist li.byuser {} | |
ol.commentlist li.comment-author-admin {} | |
ol.commentlist li.comment { border-bottom: 1px solid #ddd; padding:1em; margin-bottom: 10px; } | |
ol.commentlist li div.comment-author {} | |
ol.commentlist li div.vcard { font-size:20px;} | |
ol.commentlist li div.vcard cite.fn { font-style:normal; } | |
ol.commentlist li div.vcard cite.fn a.url {} | |
ol.commentlist li div.vcard img.avatar {float:left; margin:0 1em 1em 0; } | |
ol.commentlist li div.vcard img.avatar-32 {} | |
ol.commentlist li div.vcard img.photo {} | |
ol.commentlist li div.vcard span.says {} | |
ol.commentlist li div.commentmetadata {} | |
ol.commentlist li div.comment-meta { font-size:9px; margin-bottom: 10px;} | |
ol.commentlist li div.comment-meta a { color: #aaa; } | |
ol.commentlist li p { margin: 0; } | |
ol.commentlist li ul { list-style:square; margin:0 0 1em 2em; } | |
ol.commentlist li div.reply { font-size:11px; } | |
ol.commentlist li div.reply a { font-weight:bold; } | |
ol.commentlist li ul.children { list-style:none; margin:1em 0 0; text-indent:0; } | |
ol.commentlist li ul.children li {} | |
ol.commentlist li ul.children li.alt {} | |
ol.commentlist li ul.children li.bypostauthor {} | |
ol.commentlist li ul.children li.byuser {} | |
ol.commentlist li ul.children li.comment {} | |
ol.commentlist li ul.children li.comment-author-admin {} | |
ol.commentlist li ul.children li.depth-2 { margin:0 0 .25em .25em; } | |
ol.commentlist li ul.children li.depth-3 { margin:0 0 .25em .25em; } | |
ol.commentlist li ul.children li.depth-4 { margin:0 0 .25em .25em; } | |
ol.commentlist li ul.children li.depth-5 {} | |
ol.commentlist li ul.children li.odd {} | |
ol.commentlist li.even { background:#fff; } | |
ol.commentlist li.odd { background:#f6f6f6; } | |
ol.commentlist li.parent { } | |
ol.commentlist li.pingback { margin: 0 0 10px; padding: 1em; border: 1px dashed #ccc; } | |
ol.commentlist li.thread-alt { } | |
ol.commentlist li.thread-even { } | |
ol.commentlist li.thread-odd {} | |
/* ===================== comment form ===================== */ | |
#respond {position: relative;} | |
#respond input[type="text"],#respond textarea {border:1px solid #ddd;padding:10px} | |
#respond input[type="text"] {padding:7px;width:300px} | |
#respond .comment-form-author, | |
#respond .comment-form-email, | |
#respond .comment-form-url, | |
#respond .comment-form-comment { position: relative; } | |
#respond .comment-form-author label, | |
#respond .comment-form-email label, | |
#respond .comment-form-url label, | |
#respond .comment-form-comment label { background: #eee; color: #555; display: inline-block; left: 4px; min-width: 60px; padding: 4px 10px; position: relative; top: 40px; z-index: 1; } | |
#respond input[type="text"]:focus, | |
#respond textarea:focus { text-indent: 0; z-index: 1; } | |
#respond textarea { resize: vertical; width: 95%; } | |
#respond .comment-form-author .required, | |
#respond .comment-form-email .required { color: #bd3500; font-size: 22px; font-weight: bold; left: 75%; position: absolute; top: 45px; z-index: 1; } | |
#respond .comment-notes, | |
#respond .logged-in-as { font-size: 13px; } | |
#respond p { margin: 10px 0; } | |
#respond .form-submit { float: right; margin: -20px 0 10px; } | |
#respond input#submit { background: #454545; border: none; -moz-border-radius: 3px; border-radius: 3px; -webkit-box-shadow: 0px 1px 2px rgba(0,0,0,0.3); -moz-box-shadow: 0px 1px 2px rgba(0,0,0,0.3); box-shadow: 0px 1px 2px rgba(0,0,0,0.3); color: #eee; cursor: pointer; padding: 5px 42px 5px 22px; } | |
#respond input#submit:active { background: #86222D; color: #fff; } | |
#respond #cancel-comment-reply-link { color: #666; margin-left: 10px; text-decoration: none; } | |
#respond .logged-in-as a:hover, | |
#respond #cancel-comment-reply-link:hover { text-decoration: underline; } | |
.commentlist #respond { margin: 1.625em 0 0; width: auto; } | |
#reply-title { color: #373737; font-size: 20px; } | |
#cancel-comment-reply-link { color: #888; display: block; position: absolute; right: 1.625em; text-decoration: none; text-transform: uppercase; top: 1.1em; } | |
#cancel-comment-reply-link:focus, | |
#cancel-comment-reply-link:active, | |
#cancel-comment-reply-link:hover { color: #ff4b33; } | |
#respond label {display: block; float: right; font-size: 16px; line-height: 2.2em; width: 280px;} | |
#respond input[type=text] {} | |
#respond p { font-size: 12px; } | |
p.comment-form-comment { margin: 0; } | |
.form-allowed-tags { display: none; } | |
.trackback { margin: 0 0 10px; padding: 1em; border: 1px dashed #ccc; } | |
functions.php | |
For enable comment | |
===================================== | |
function comment_scripts(){ | |
if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); | |
} | |
add_action( 'wp_enqueue_scripts', 'comment_scripts' ); | |
For enable featured image | |
add_theme_support( 'post-thumbnails', array( 'post' ) ); | |
for enable crop feature | |
set_post_thumbnail_size( 200, 200, true ); | |
add_image_size( 'post-image', 150, 150, true ); | |
post-loop.php | |
Using Featured Image | |
<?php the_post_thumbnail('post-image', array('class' => 'post-thumb')); ?> | |
For Dynamic Menu | |
functions.php | |
===================================== | |
add_action('init', 'wpj_register_menu'); | |
function wpj_register_menu() { | |
if (function_exists('register_nav_menu')) { | |
register_nav_menu( 'main-menu', __( 'Main Menu') ); | |
} | |
} | |
header.php | |
<?php wp_nav_menu( array( 'theme_location' => 'main-menu') ); ?> | |
An amazing readmore function | |
functions.php | |
===================================== | |
function excerpt($num) { | |
$limit = $num+1; | |
$excerpt = explode(' ', get_the_excerpt(), $limit); | |
array_pop($excerpt); | |
$excerpt = implode(" ",$excerpt)." <a href='" .get_permalink($post->ID) ." ' class='".readmore."'>Read | |
More</a>"; | |
echo $excerpt; | |
} | |
Usage: <?php echo excerpt('15'); ?> | |
Using Custom Templates | |
===================================== | |
<?php | |
/* | |
* Template Name: Custom Template Name | |
*/ | |
get_header(); ?> | |
Query Post from a specific category | |
===================================== | |
<?php query_posts('post_type=post&post_status=publish&posts_per_page=10&paged='. | |
get_query_var('paged')); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment