3 technique Creating Custom page
- conditional approach if(is_page())
- template file with page- followed by slug or page id [page-*]
- custom template directly by different page name . Then select that template from admin panel
function
- get_header(); //render header content
- get_footer(); // render footer content
The post function
- have_posts(); // return true/false- the_post(); // return post
- get_the_author();
- get_the_date({php date string});
- the_content('continue reading..'); // for single post
- the_excerpt(); // use in view file result for all post
this will add input excerpt in admin post edit...
- get_the_excerpt(); // we need to add manual link to detail
- the_permalink();
- the_time('php_date_string'); // get posted date
-the_title(); // get title for post
- the_author(); // get author for post
- get_author_post_url({author_id});
- get_the_author_meta('ID'); // retirn author_id for given posi_id {ID}
To check for archive...
// url type- is_category(); // if post has category boolean
- is_tag();
- is_day();
- is_month();
- is_year();
Category function
- get_the_category(); // return array of category for the post- get_category_link({category_id}); // return category link
for loop to get single one..
$categories = get_the_category();
foreach($categories as $category) {
$catname = $category-> cat_name ;
$catId = $category->term_id;
}
Feature Image
function func_to_call_theme_support(){
// add feature image support
add_theme_support();
//image size
//add_image_size('thumb_name', width,height , true);
add_image_size('small_thumb', 120, 150 , true);
//crop image with 4th param
add_image_size('small_thumb', 120, 150 , array('left','top')); // crop form lrft top
add_image_size('banner_thumb', 120, 150 , array('left','top')); // crop form lrft top
// or we can crop from admin panel
}
add_action('after_setup_theme','func_to_call_theme_support');
//to use image in view file
- the-post_thumbnail('small_thumb');
Pages
- homepage template. page.php > front-page.php