Steps Add the PHP code to your theme’s functions.php file or a PHP snippets plugin. Save and activate the snippet. Search for a keyword that matches exactly one post. WordPress will redirect directly to that post.
Steps Add the PHP code to your theme’s functions.php file or a PHP snippets plugin. Replace 5, 8, 12 with your actual WordPress category IDs. Save and activate the snippet. Search your website to verify the excluded categories no longer appear.
/** * Exclude pages from WordPress search results */ function custom_exclude_pages_from_search( $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { $query->set( ‘post_type’, ‘post’ ); } } add_action( ‘pre_get_posts’, ‘custom_exclude_pages_from_search’ );
/** * Add copyright text to WordPress RSS feed content */ function custom_add_rss_copyright_notice( $content ) { if ( is_feed() ) { $copyright = ‘<p>Copyright © ‘ . esc_html( gmdate( ‘Y’ ) ) . ‘ Your Website Name. All rights reserved.</p>’; $content .= $copyright; } return $content; } add_filter( ‘the_content_feed’, ‘custom_add_rss_copyright_notice’ );
Steps Add the PHP code to your theme’s functions.php file or a PHP snippets plugin. Save and activate the snippet. Log in with different WordPress user roles. Inspect the page’s HTML body class.
Steps Add the PHP code to your theme’s functions.php file or a PHP snippets plugin. Save and activate the snippet. New posts will have comments and pingbacks disabled by default.
Steps Add the PHP code to your theme’s functions.php file or a PHP snippets plugin. Save and activate the snippet. Make a blog post Sticky from the WordPress post settings. The post title will automatically display a Featured label.
Steps Add the PHP code to your theme’s functions.php file or a PHP snippets plugin. Save and activate the snippet.
/** * Add a “Popular” label to posts with many comments */ function custom_add_popular_post_label( $title, $post_id ) { if ( is_admin() || get_post_type( $post_id ) !== ‘post’ ) { return $title; } $comment_count = get_comments_number( $post_id ); if ( $comment_count >= 10 ) { $title .= ‘ <span class=”popular-post-label”>Popular</span>’; } return $title; } add_filter( ‘the_title’, […]
Steps Add the PHP code to your theme’s functions.php file or a PHP snippets plugin. Save and activate the snippet. Update any blog post. Posts updated within the last 7 days will display an Updated Recently label.