Some Basic But Useful WordPress Functions
In this tutorial of PHP Point we will show you some basic but important functions of WordPress.
Here is the list of top 10 functions which are commonly used during wordpress website development.
1 – $current_category = single_cat_title(“”, false);
Display current category Title.
Here is the list of top 10 functions which are commonly used during wordpress website development.
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 current 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 according 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.
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 current 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 according 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 Point for more Codes.