HTML to WordPress
Convert HTML to WordPress theme part-2
Convert HTML to WordPress theme part-1 in this tune I start how to convert HTML to wordpress theme development. In this I going to describe more about wordpress theme development.
10. To register widget:
In functions.php file:
function my_custom_theme_widgets() { register_sidebar( array( 'name' => 'Widget Name', 'id' => 'widget_id', 'before_widget' => '<div class="single_sidebar fix">', 'after_widget' => '</div>', 'before_title' => '<h2>', 'after_title' => '</h2>', ) ); } add_action('widgets_init', 'my_custom_theme_widgets');
Usages: Here widget id is important to use widget.
<?php dynamic_sidebar('widget_id'); ?> //Or <?php if ( ! dynamic_sidebar('widget_id') ) : ?> //Default HTML will be here, This is show if not set widget. <?php endif; ?>
11. Single.php and page.php file
Common in content section:
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?> <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a> <?php the_content(); ?> //here can be more dynamic php code are given below <?php endwhile; ?> <?php else : ?> <h2>404 not found!</h2> <?php endif; ?>
More dynamic php code:
<p><?php the_excerpt();?></p> <?php the_author_posts_link(); ?> <?php the_time('F jS, Y'); ?> <?php the_category(', '); ?> <p><?php the_tags(); ?></p> or <?php the_tags( 'Tagged with: ', ' • ', '<br />' ); ?> <?php the_post_thumbnail('image_size', array('class' => 'class_name')); ?> <?php edit_post_link('{Edit}'); ?> <?php previous_post_link(' %', 'Previous Post: ', 'yes'); ?> <?php next_post_link('% ', 'Next Post: ', 'yes'); ?> <?php comments_template( '', true ); ?> <?php comments_popup_link('No Comment', '1 Comment', '% Comments'); ?> or <?php if ( comments_open() ) : ?> <?php comments_popup_link('No Comment', '1 Comment', '% Comments'); ?> <?php endif; ?> <?php the_ID(); ?> or <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
If can not understand any code search on google or comment here.
Comments are closed