Category Archives: PHP

Breadcrumbs in SEO Yoast plugin

Adding Yoast SEO breadcrumbs in WordPress.

Just add the below PHP code where you want to show breadcrumbs on your page.


<?php
if ( function_exists('yoast_breadcrumb') ) {
  yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
}
?>

You can use shortcode instead of PHP code.


[wpseo_breadcrumb]

How to exclude specific blog categories from blog archive page

Hey Friends,
If you want to remove or hide any specific blog categories from the blog archive page in WordPress. So you just need to add the below function or hook in function.php file in your theme folder.


   function exclude_category( $query ) {
   if ( $query->is_home() && $query->is_main_query() ) {
   $query->set( 'cat', '-1, -2' ); //The IDs of the categories to exclude.
   }
   }
   add_action( 'pre_get_posts', 'exclude_category' );