Advertisement
fauzanjeg

Change Sidebar for Single Post || Example change by ID and Category

Dec 7th, 2021
1,588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. /* Change Sidebar for Single Post || Example change by ID and Category */
  2. function spesific_sidebar_for_single_post( $sidebar, $post_id ) {
  3.     if ( in_array( $post_id, array( '54309' ) ) ) { /* Check by ID Post */
  4.         $sidebar = 'footer-widget-1';
  5.     }
  6.  
  7.     if ( in_category( 'startup', $post_id ) ) { /* Check by Category Post */
  8.         $sidebar = 'footer-widget-2';
  9.     }
  10.     return $sidebar;
  11. }
  12. add_filter( 'jnews_single_post_sidebar', 'spesific_sidebar_for_single_post', null, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement