fauzanjeg

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

Dec 7th, 2021
1,220
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 );
RAW Paste Data