WordPress has a library of giant pre-written content (Approximately 3240 PHP functions). Here I just introduce some popular functions in WordPress template
Function to get website information
get_bloginfo ($show)
$show can be:
'Name' - Returns the title Website
'Description' - Returns the description Website
'ADMIN_EMAIL' - Returns the admin's email
'SITE_URL' - Returns the url of the website
'Home' - Returns the home url
Functions to get content
get_header('header_name') - Get content from a header php file
For example:
we have header_for_homepage.php then can call <?php get_header('for_homepage');?>
Default is <?php get_header();?> to call header.php
get_footer ('footer_name') - Get content from a footer php file
For example:
we have footer_for_homepage.php then can call <?php get_footer('for_homepage');?>
Default is <?php get_footer();?> to call footer.php
get_sidebar ('sidebar_name') - Get content from a sidebar php file
For example:
we have sidebar_for_homepage.php then can call <?php get_sidebar('for_homepage');?>
Default is <?php get_sidebar();?> to call sidebar.php
The function used for Post, Page, Custom Post Type, Attachment
the_ID() - Print the ID of the current posts. If you want to get ID paper we use get_the_ID function() (can use $Post->ID)
the_title() - Print the title of the current posts. Get Text get_the_title article we use () (can use $Post-> POST_TITLE)
the_content() - Print the article content (the_content filter has passed). Get Content article get_the_content () (can use $Post-> post_content)
the_author() - Print the post author name. Get author names we use get_the_author (). Get ID of the author $Post-> post_author
the_category (',') - Print a list of article categories, separated by ','
the_time ('{date format}') - In a paper published time. For example: the_time('dm-Y') will print 09-19-2014
the_permalink() - Print out a link to the article. Get get_the_permalink article link() or get_permalink($Post->ID)
the_post_thumbnail($size, $attr) - show the featured thumbnail for post
For example: the_post_thumbnail('large', array ('alt' = 'my image description'))
Loop in WordPress
<?php if (have_posts ()):?> If have posts
<?php endif; ?> Close conditions
<?php while (have_posts ()): the_posts (); ?> Loop and show content (posts), you can add conditions in these loops
<?php endwhile;?> End loop
Hope I showed you popular commands that used to use in WP. If you have any questions, let me know
Regards,
Alex