Wordpress Code


1. Title 

 <?php the_title(); ?>

2. Content 

 <?php the_content(); ?> 
 

3. Content Minimum word

<?php $content = get_the_content(); echo mb_strimwidth($content, 0, 150, '...'); ?>

4. Sidebar

<?php get_sidebar(); ?>
 
5. Menu

<?php wp_nav_menu(array('menu' => 'place menu name')); ?>
 
Static : <?php echo home_url(); ?>

6. Permalink

<?php the_permalink(); ?>

7. Directory 

 <?php echo get_template_directory_uri(); ?>

8. Categorie Title 

 <?php printf( __( 'Category Archives: %s', 'twentythirteen' ), single_cat_title( '', false ) ); ?> 

9. Image Thumbnail 

 <?php the_post_thumbnail(); ?> 

you can pass the class you want to use to the_post_thumbnail() as part of the attributes argument, for example  

<?php the_post_thumbnail('thumbnail', array('class' => 'your-class-name')); ?>

10. Short Code 

 <?php echo do_shortcode( '[enter your code]' ); ?>


11. Wordpress Search

 <form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">

<label class="screen-reader-text" for="s"><?php _x( 'Search for:', 'label' ); ?></label>

 <input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" />

<input type="submit" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" />

</form>

12. Page Template 

 <?php
/** *
Template Name: Enter Page Name
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0 */ get_header(); ?>


<?php get_footer(); ?>

13. Categories

 <?php
$args = array( 'posts_per_page' => 2000, 'offset'=> 0, 'category' => 2 );
$myposts = get_posts( $args );
 foreach ( $myposts as $post ) : setup_postdata( $post ); ?>


 Add Your Design
 
 <?php endforeach; wp_reset_postdata();?>


14. Page Code

<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>


 Add Your Design



<?php endwhile; ?> 
 
 
15. Date
 <?php echo get_the_date(); ?> 


16. Author
 <?php echo get_the_author(); ?>
 
17. Comment
 <?php echo get_the_author(); ?>
 
17. Woo Commerce Product Categories
 <?php
$args = array(
'post_type' => 'product',
'product_cat' => 'Mention Categories Name',
'stock' => 1,
'posts_per_page' => 20,
'orderby' =>'date',
'order' => 'DESC' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
 
 Add Your Design
 
<?php endwhile; ?>
    <?php wp_reset_query(); ?> 
 
 
18. Price
 
<?php echo $product->get_price_html(); ?>
 
 


Wordpress Code Wordpress Code Reviewed by webmission on 11:41 Rating: 5

No comments:

Powered by Blogger.