Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // remove junk from head
- remove_action('wp_head', 'rsd_link');
- remove_action('wp_head', 'wp_generator');
- remove_action('wp_head', 'feed_links', 2);
- remove_action('wp_head', 'index_rel_link');
- remove_action('wp_head', 'wlwmanifest_link');
- remove_action('wp_head', 'feed_links_extra', 3);
- remove_action('wp_head', 'start_post_rel_link', 10, 0);
- remove_action('wp_head', 'parent_post_rel_link', 10, 0);
- remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
- // add custom post content
- function add_post_content($content) {
- if(!is_feed() && !is_home()) {
- $content .= '<p>This article is copyright © '.date('Y').' '.bloginfo('name').'</p>';
- }
- return $content;
- }
- add_filter('the_content', 'add_post_content');
- // delay feed update
- function publish_later_on_feed($where) {
- global $wpdb;
- if (is_feed()) {
- // timestamp in WP-format
- $now = gmdate('Y-m-d H:i:s');
- // value for wait; + device
- $wait = '5'; // integer
- // http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
- $device = 'MINUTE'; // MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
- // add SQL-sytax to default $where
- $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
- }
- return $where;
- }
- add_filter('posts_where', 'publish_later_on_feed');
- // add custom dashboard widget
- add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');
- function my_custom_dashboard_widgets() {
- global $wp_meta_boxes;
- wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help');
- }
- function custom_dashboard_help() {
- echo '<p>Welcome to Custom Blog Theme! Need help? Contact the developer <a href="mailto:yourusername@gmail.com">here</a>. For WordPress Tutorials visit: <a href="https://www.wpbeginner.com" target="_blank">WPBeginner</a></p>';
- }
- // Featured image in feed
- function rss_post_thumbnail($content) {
- global $post;
- if(has_post_thumbnail($post->ID)) {
- $content = '<p>' . get_the_post_thumbnail($post->ID) .
- '</p>' . get_the_content();
- }
- return $content;
- }
- add_filter('the_excerpt_rss', 'rss_post_thumbnail');
- add_filter('the_content_feed', 'rss_post_thumbnail');
- //add admin user (if forgot password)
- function wpb_admin_account(){
- $user = 'Username';
- $pass = 'Password';
- $email = 'email@domain.com';
- if ( !username_exists( $user ) && !email_exists( $email ) ) {
- $user_id = wp_create_user( $user, $pass, $email );
- $user = new WP_User( $user_id );
- $user->set_role( 'administrator' );
- } }
- add_action('init','wpb_admin_account');
- //Exclude categories from RSS
- function exclude_category($query) {
- if ( $query->is_feed ) {
- $query->set('cat', '-5, -2, -3');
- }
- return $query;
- }
- add_filter('pre_get_posts', 'exclude_category');
Add Comment
Please, Sign In to add comment