Monday, 24 June 2013

Some Basic But Useful WordPress Functions | PHP Tutorial for Beginners

In this tutorial for Php Tutorial for Beginners we will show you some basic but important functions of WordPress

1 - $current_category = single_cat_title("", false);
Display current category Title.

2 - $permalink = get_permalink( $id ); 
Returns the permalink to a post or page for use in PHP. 

3 - $cat_id = get_cat_ID( $cat_name ) ;
Retrieve the ID of a category from its name.

4 - $current_user = wp_get_current_user(); 
Retrieve the current user object.

5 - $current_user_id = get_current_user_id( ); 
Returns the ID of the current viewer if they are logged in. Returns 0 if the viewer is not logged in.

6 - $title = get_the_title();
Return the cureent post/page title.

7 - $posts = get_posts( array('numberposts' => 6,'orderby' => 'post_date','order' => 'DESC','post_type' => 'post','post_status' => 'publish' ) );
Get the posts from database accroding to the argument passed in it.

8 - get_header()
Add Header page to the file.

9 - bloginfo('home')
Fetch the URL of your home page.

10 - the_content()
Displays the contents of the current post. This template tag must be within the loop.

Hope this php tutorial is useful for you. Keep following Php Tutorial for Beginners for more Codes.

1 comment:

  1. can you give a tutorial on login and signup(email confirmation) as per the standards in the industry?It will be a big help...

    Thanks

    ReplyDelete