How To Create Your Own Shortcode For Clear Property in WordPress

When writing HTML code or working with WordPress pages, we often come across a situation where we want to clear areas and put next div or element on next line instead of floating with previous block. You can write quick HTML to fix such issues. But in case of repeated situation, you may create this handy code using WordPress shortcode feature. Add the following lines in your theme's funtions.php and use the [clear] shortcode you clear the areas on left and right in HTML. Step 1: function ad_clear_shortcode( $atts , $content = null ) { // Code return ''; } add_shortcode( 'clear',...

How To Change Default WordPress Excerpt Length

If you want to change the default excerpt length of a WordPress site, you can do it using the code below. Paste it in the funtions.php file and update the number in line 9. remove_filter('get_the_excerpt', 'wp_trim_excerpt'); function custom_trim_excerpt($text) { global $post; if ( '' == $text ) { $text = get_the_content(''); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $excerpt_length = 75; $words = explode(' ', $text, $excerpt_length + 1); if (count($words) > $excerpt_length) { array_pop($words); array_push($words,...