Monday, December 22, 2014

Some important script of wordpress

   Must be important:

<?php bloginfo('name'); ?> = To active blog name
<?php bloginfo('home'); ?> = home option
<?php the_content(); ?> = get content
<?php the_time('d M, Y') ?> =  date
<?php comments_popup_link('0', '1', '%'); ?>= for comment
<?php the_author(); ?> = admin call 
<?php the_excerpt(); ?> = content summery
<?php echo get_template_directory_uri(); ?> = dynamic theme directory
<?php bloginfo('stylesheet_url'); ?> = To get dynamic stylesheet
<?php wp_head(); ?> = To get header script
<?php wp_footer(); ?> = To get footer script
<?php wp_title( '|', true, 'right' ); ?> = For Title Dynamic
<?php echo do_shortcode('[contact-form-7 id="27" title="slider contact"]'); ?>: Shortcode to active for contact 7

Pagination code for post or blog: 

At first you paste below this code in function.php:

function pagination($pages ''$range 4)
    {
         
$showitems = ($range 2)+1;

         global 
$paged;
         if(empty(
$paged)) $paged 1;

         if(
$pages == '')
         {
             global 
$wp_query;
             
$pages $wp_query->max_num_pages;
             if(!
$pages)
             {
                 
$pages 1;
             }
         }

         if(
!= $pages)
         {
             echo 
"<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
             if(
$paged && $paged $range+&& $showitems $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo; First</a>";
             if(
$paged && $showitems $pages) echo "<a href='".get_pagenum_link($paged 1)."'>&lsaquo; Previous</a>";

             for (
$i=1$i <= $pages$i++)
             {
                 if (
!= $pages &&( !($i >= $paged+$range+|| $i <= $paged-$range-1) || $pages <= $showitems ))
                 {
                     echo (
$paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
                 }
             }

             if (
$paged $pages && $showitems $pages) echo "<a href=\"".get_pagenum_link($paged 1)."\">Next &rsaquo;</a>";
             if (
$paged $pages-&&  $paged+$range-$pages && $showitems $pages) echo "<a href='".get_pagenum_link($pages)."'>Last &raquo;</a>";
             echo 
"</div>\n";
         }
    } 


Then you paste below this code in style.css:


/* For Pagination Css */.pagination{clear:both;font-size:11px;line-height:13px;margin-left:35px;padding:20px 0;
}
.
pagination span, .pagination a{display:block;float:left;margin:2px 2px 2px 0;padding:6px 9px 5px 9px;text-decoration:none;width:auto;color:#fff;background:#555;}
.
pagination a:hover{color:#fff;background:#3279BB;}
.
pagination .current{padding:6px 9px 5px 9px;background:#3279BB;color:#fff;


Finally you cope below this code and paste where you can pagination in blog: 

<?php if (function_exists("pagination")) {
        
pagination($additional_loop->max_num_pages);
    } 
?>

Widget Registation in Wordpress:

Firstly you should sidebar registration by below this code:

Sideber.php:

<?php if ( ! dynamic_sidebar( 'sidebar-top' ) ) : ?>
  <p>faridul is not nice boyfaridul is not nice boyfaridul is not nice boyfaridul is not nice boy< /p>
<?php endif; ?>

Nextly you copy below this code and paste in function.php:

* Register sidebars and widgetized areas ********************************************/

function faridul_widget_areas() {
register_sidebar( array(
'name' => __( 'Welcome Text', 'faridul' ),
'id' => 'welcome-text',
'description' => __( 'Plese write document', 'faridul' ),
'before_widget' => '<div class="col-sm-8">',
'after_widget' => '</div>',
'before_title' => '<h2 class="text-title">',
'after_title' => '</h2>',
) );
}
add_action('widgets_init', 'faridul_widget_areas');

 

 

No comments:

Post a Comment