L O A D I N G
Profile image
blog banner

10 Useful WordPress functions to reduce your development time

This 10 Useful WordPress functions will certainly reduce your WordPress development time.I found this functions when i do some research for my projects. So i think i better share this with you.

1.Custom Excerpt Length

By default, excerpt length is set to 55 words. To change excerpt length using excerpt_length filter, add the following code to functions.php file in your theme:

function custom_excerpt_length( $length ) {
	return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

Find more here.

2. Human Time

echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago';
// display "2 days ago"

Find more here.

3. Validate String

wp_kses($string, $allowed_html, $allowed_protocols);

This only allow HTML element names, attribute names and attribute values to the inputted string.

Find more here .

4. Use wp mail function to send email

 wp_mail( $to, $subject, $message, $headers, $attachments ); 

The benefit of using this function to send email is its super simple.

Find more here.

5. Wp schedule event

wp_schedule_event($timestamp, $recurrence, $hook, $args);

Using this function you can do cron job after specific time interval.

Find more here.

6. Wp redirect function

wp_redirect( $location, $status );
exit;

Using this you can redirect a use to a specific link for a specific event.Lets say if your not logged in then you want to redirect user to login page.

Find more here.

7. Is email function

is_email( $email );

using this function you can verifies that an email is valid or not.

Find more here.

8. Absint function

absint( $maybeint );

This function will converts a value to a non-negative integer.Very useful for integer verification.

Find more here.

9. Wp remote get function

wp_remote_get( $url, $args );

Use this function if you want to retrieve the content of a Webpage.You will get the content in a array.Usin this function you can get feed data also.

Find more here.

10. Wp remote get function

$feed = fetch_feed( $uri );

This function will retrieves an external feed and parses it. Uses the SimplePie and FeedCache functionality for retrieval and parsing and automatic caching.

Find more here.