Advertisement
arie_cristianD

display custom post type on category pages

Jan 6th, 2025
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. add_filter( 'jnews_get_content_attr', 'change_post_type', 99, 3 );
  2.  
  3.  
  4. function change_post_type( $attr, $prefix, $id ) {
  5.  
  6. if ( 'jnews_category_' === $prefix ) {
  7.  
  8. $originals_cat_id = array( '_49', '_50' ); /* add your originals post category ids list with _ prefix */
  9.  
  10. if ( in_array( $id, $originals_cat_id ) ) {
  11. $attr['post_type'] = array( 'originals', 'posts' ); /* use this code if you want to display posts & originals post type */
  12.  
  13. $attr['post_type'] = 'originals'; /* use this code if you only want to display originals post type */
  14. }
  15. }
  16.  
  17. return $attr;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement