The number of mobile users across globe is forecast to reach an astonishing 2.87 billion, & based on socPub 57% of users say they will not recommend a business with a poor quality mobile responsive site.
Fortunately, creating a fully responsive website is ease with WordPress, particularly when you go for latest WordPress themes.
WordPress is the most popular content management system (CMS) for many websites as it is highly user-friendly and customizable, making it a popular choice at ColorWhistle for client projects.
If you’re familiar with custom WordPress theme development, you know things can get messy, especially if you’re starting from the scratch.
So, how should you go about doing it?
We ColorWhistle WordPress web development company in India are going to save you the trouble by providing some common WordPress functions list used in custom theme development.
With the help of our WordPress developers, I have provided a basic overview of how to incorporate those functions into a WordPress website.
WordPress Functions List
- How to show individual (Single) post content in front-end?
if(have_posts()) : while(have_posts()) : the_post();
the_title();
echo ‘‘;
the_content();
if(get_post_meta($post->ID, ‘key-name’, true)){
echo get_post_meta($post->ID, ‘key-name’, true);
}
echo ‘‘;
endwhile; endif;
?> - How to list custom post-type?
‘paged’ => $paged,
‘posts_per_page’ => $postsPerPage);$loop = new wp_query($args);
if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post(); ?>
‘next_text’ => __( ‘Next page’, ‘cbc’ ),
‘before_page_number’ => ” . __( ‘Page’, ‘cbc’ ) . ‘ ‘,
) );
?>
For example, if you require a post type as ‘travel’, you have to add, ‘post_type’ => ‘travel’, - How to list child pages?
‘posts_per_page’ => 1, // number of posts (pages) to show
‘page_id’ => 81, // enter the post ID of the parent page
‘no_found_rows’ => true, // no pagination necessary so improve efficiency of loop
) );
if ( $child_pages->have_posts() ) : while ( $child_pages->have_posts() ) : $child_pages->the_post();
the_title( ‘‘, ‘
‘ );
get_template_part( ‘template-parts/content’, ‘page’ );
endwhile; endif;
wp_reset_postdata();
?> - How to use ‘User meta’ function?
-
add_user_meta
Ex: -
update_user_meta
Ex:
$user_id = 1;
$website = ‘http://wordpress.org’;
update_user_meta($user_id, ‘user_url’, $website);
? -
delete_user_meta
Ex: -
get_user_meta
Ex:
$user_id = 9;
$key = ‘last_name’;
$single = true;
$user_last = get_user_meta( $user_id, $key, $single );
echo ‘The ‘. $key . ‘ value for user id ‘ . $user_id . ‘ is: ‘ . $user_last . ‘
‘;
?> -
$user_id
(integer) (required) user ID
Default: None -
$meta_key
(string) (required) Metadata name.
Default: None -
$meta_value
(mixed) (required) Metadata value. (Don’t serialize it yourself, WordPress will do it for you.)
Default: None -
$unique
(boolean) (optional) Whether the same key should not be added.
Default: false -
$prev_value
(mixed) (optional) Previous value to check before removing.
Default: ” -
$single
(boolean) (optional) If true return value of metadata field, if false return an array. This parameter has no effect if $key is left blank.
Default: false -
$before
(string) (optional) Text to place before the date.
Default: None -
$after
(string) (optional) Text to place after the date
Default: None -
$echo
(boolean) (optional) Display the date (TRUE), or return the date to be used in PHP (FALSE).
Default: TRUE
-
- How to include date/time function?
Posted: at
F j, Y g:i a – November 6, 2010 12:50 am
F j, Y – November 6, 2010
F, Y – November, 2010
g:i a – 12:50 am
g:i:s a – 12:50:48 am
l, F jS, Y – Saturday, November 6th, 2010
M j, Y @ G:i – Nov 6, 2010 @ 0:50
Y/m/d at g:i A – 2010/11/06 at 12:50 AM
Y/m/d at g:ia – 2010/11/06 at 12:50am
Y/m/d g:i:s A – 2010/11/06 12:50:48 AM
Y/m/d – 2010/11/06Date as Year, Month, Date in Heading - How to use tags in WordPress website?
– Displays the posts/pages title – Displays the content of the post/page
– Displays the excerpt of the current post/page
– Displays the time of the current post/page
– Displays the date of a post or set of post/page - How to create a Taxonomy?
Here is an example of registering a “people” taxonomyfunction people_init() {
// create a new taxonomy
register_taxonomy(
‘people’,
‘post’,
array(
‘label’ => __( ‘People’ ),
‘rewrite’ => array( ‘slug’ => ‘person’ ),
‘capabilities’ => array(
‘assign_terms’ => ‘edit_guides’,
‘edit_terms’ => ‘publish_guides’
)
)
);
}
add_action( ‘init’, ‘people_init’ );Here is an example of adding the term John to post id number 555 in the “person” taxonomy.
wp_set_object_terms( 555, ‘John’, ‘person’ ); - How to display Terms?
The following is an example of the_terms() function:
- How to add login/logout links to WordPress menu?
To add a signup and login/logout links to your WordPress menu, add the code snippet below to your theme’s functions.php file.function add_login_logout_register_menu( $items, $args ) {
if ( $args->theme_location != ‘primary’ ) {
return $items;
}if ( is_user_logged_in() ) {
$items .= ‘ - ‘ . __( ‘Log Out’ ) . ‘
-
‘;
} else {
$items .= ‘ - ‘ . __( ‘Login In’ ) . ‘
-
‘;
$items .= ‘ - ‘ . __( ‘Sign Up’ ) . ‘
-
‘;
}
return $items;
}
add_filter( ‘wp_nav_menu_items’, ‘add_login_logout_register_menu’, 199, 2 ); - How to add categories?
-
get_cat_ID
return 0;
}
?> -
Get_cat_name
}
?> -
Get_categories
“type” => “post”,
“orderby” => “name”,
“order” => “ASC” );
$types = get_categories($args);
?> -
Get_category
get_the_category_list
in_category
You’re in the vegetarian category -
Is_category
-
- How to insert the post manually or custom?
Post insertion/removal
-
wp_delete_post
-
Wp_insert_post
‘post_author’ => $user->ID,
‘post_category’ => array($post_category),
‘post_content’ => $post_content,
‘post_title’ => $post_title,
‘post_status’ => ‘publish’
);$post_id = wp_insert_post($new_post);
// This will redirect you to the newly created post
$post = get_post($post_id);
wp_redirect($post->guid);
}
?> -
get_the_ID
echo ‘‘;
?> -
Get_the_content
-
the_content and get_the_title
the_title
-
- Shortcodes
-
Add_shortcode
function fun_name( $atts ) {
return “foo = {$atts[‘foo’]}”;
}
add_shortcode( ‘shotcode_name’, ‘fun_name’ ); -
Do_shortcode
-
Winding Up Our WordPress Functions List
We hope this article helped you learn some useful tricks on commonly used WordPress functions list in custom theme development. Make sure to treat your functions with care and it will help your theme development.
If you need any help with custom theme development, our developers at ColorWhistle are always ready to help. If you decide to work with us, you’ll get an attractive responsive design with peak functionality.
Hire WordPress developers if you’re bored of the standard themes available in the market and looking out for something unique and exciting.
Here’s an infographic that sums up the entire post.


I have figured out some important things through your blog post post.