Disable Attachment Pages

add_action( ‘template_redirect’, function () { global $post; if ( ! is_attachment() || ! isset( $post->post_parent ) || ! is_numeric( $post->post_parent ) ) { return; } // Does the attachment have a parent post? // If the post is trashed, fallback…Continue reading

Disable RSS Feeds

/** * Display a custom message instead of the RSS Feeds. * * @return void */ function wpcode_snippet_disable_feed() { wp_die( sprintf( // Translators: Placeholders for the homepage link. esc_html__( ‘No feed available, please visit our %1$shomepage%2$s!’ ), ‘ ‘, ‘‘…Continue reading

Change Admin Panel Footer Text

add_filter( ‘admin_footer_text’, function ( $footer_text ) { // Edit the line below to customize the footer text. $footer_text = ‘Powered by WordPress | WordPress Tutorials: WPBeginner‘; return $footer_text; } );Continue reading

Add Featured Images to RSS Feeds

/** * Add the post thumbnail, if available, before the content in feeds. * * @param string $content The post content. * * @return string */ function wpcode_snippet_rss_post_thumbnail( $content ) { global $post; if ( has_post_thumbnail( $post->ID ) ) {…Continue reading

Disable Search

// Prevent search queries. add_action( ‘parse_query’, function ( $query, $error = true ) { if ( is_search() && ! is_admin() ) { $query->is_search = false; $query->query_vars[‘s’] = false; $query->query[‘s’] = false; if ( true === $error ) { $query->is_404 =…Continue reading

Delay Posts in RSS Feeds

function wpcode_snippet_publish_later_on_feed( $where ) { global $wpdb; if ( is_feed() ) { // Timestamp in WP-format. $now = gmdate( ‘Y-m-d H:i:s’ ); // Number of unit to wait $wait = ’10’; // integer. // Choose time unit. $unit = ‘MINUTE’;…Continue reading

Change Read More Text for Excerpts

function wpcode_snippets_change_read_more( $read_more, $read_more_text ) { // Edit the line below to add your own “Read More” text. $custom_text = ‘Read the whole post’; $read_more = str_replace( $read_more_text, $custom_text, $read_more ); return $read_more; } add_filter( ‘the_content_more_link’, ‘wpcode_snippets_change_read_more’, 15, 2 );Continue reading