//hook loading of new page and edit page screens
add_action('load-page-new.php','add_custom_help_page');
add_action('load-page.php','add_custom_help_page');
function add_custom_help_page() {
//the contextual help filter
add_filter('contextual_help','custom_page_help');
}
function custom_page_help($help) {
//keep the existing help copy
echo $help;
//add some new copy
echo "<h5>Custom Features</h5>";
echo "<p>Content placed above the more divider will appear in column 1. Content placed below the divider will appear in column 2.</p>";
}
global $wp_query;
$total = $wp_query->max_num_pages;
// only bother with the rest if we have more than 1 page!
if ( $total > 1 ) {
// get the current page
if ( !$current_page = get_query_var('paged') )
$current_page = 1;
// structure of "format" depends on whether we're using pretty permalinks
$format = empty( get_option('permalink_structure') ) ? '&page=%#%' : 'page/%#%/';
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => $format,
'current' => $current_page,
'total' => $total,
'mid_size' => 4,
'type' => 'list'
));
}
Assume that we want to show 5 posts per page for category “WordPress” and 10 posts per page for category “News”, just open the functions.php file in your theme folder and insert these line into it:
add_action('pre_get_posts', 'diff_post_count_per_cat');
function diff_post_count_per_cat() {
if (is_admin()) return;
$cat = get_query_var('category_name');
switch ($cat) {
case 'wordpress':
set_query_var('posts_per_page', 5);
break;
case 'wordpress/news':
set_query_var('posts_per_page', 2);
break;
}
}
Change “wordpress” and “news” into real category names of your blog. Note that in the code above, we use category slug, not original name. If the category is a child category, don’t forget to insert full path (i.e. “wordpress/news” in the example below).
element of a theme, in header.php. Example plugin use: add JavaScript code.
Goes in footer.php, just before the closing tag. Example plugin use: insert PHP code that needs to run after everything else, at the bottom of the footer. Very commonly used to insert web statistics code, such as Google Analytics.
Typically goes in the Meta section of a Theme’s menu or sidebar; sidebar.php template. Example plugin use: include a rotating advertisement or a tag cloud.
Goes in comments.php directly before the file’s closing tag. Example plugin use: display a comment preview.