Site icon DDGPRESS

Some useful scripts, codes and hooks of wordpress

useful scripts, codes and hooks of wordpress

There are some important useful Scripts, Codes and hooks of WordPress that can be easily used for wordpress theme customization. Today we will be discuss on these useful WordPress’s scripts, Codes and hooks.

1) Code for Logo So that you can direct visit on homepage:

<a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a>

2) Code to call image from images directory using php:

<img border="none" class="icon" src="<?php bloginfo('template_directory'); ?>/images/image-name.png" />

3) Code to include other php files:

<?php include (TEMPLATEPATH . '/filename.php'); ?>

4) Code to Call page or post title:

<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

5) Code for display content part:

<?php the_content('Read the rest of this entry »'); ?>

6) Code for show post or page date:

<?php the_time('F jS, Y') ?>

How to limit content length using Exerpts

7) Paste below code in place of content:

<?php the_excerpt(); ?>

Now paste this code in your theme functions.php file:

function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');
Exit mobile version