Support » Plugin: Jetpack - WP Security, Backup, Speed, & Growth » Trouble restricting post category on JetPack Mobile home page

  • Hello,
    I I’m using JetPack 3.0.2 and WordPress 3.9.1. I have a custom functions.php file in my child theme.

    I’m trying to exclude a category from my JetPack Mobile theme and it seems to ignore the code found here:
    http://jetpack.me/2014/02/26/exclude-a-category-from-mobile-theme/

    I have replaced the “-1” with my desired category (-171) but the posts in that category still show.

    I’m using the following code in my functions.php to exclude category 171 for the non-mobile theme with no problems:

    function my_exclude_category( $query ) {
    
      if ( $query->is_home ) {
    		$query->set( 'cat', '-171' );
    	}
    
    	return $query;
    }
    add_filter( 'pre_get_posts', 'my_exclude_category' );

    I also tried removing all other functions from the functions.php file to make sure nothing was interfering, but that still didn’t work.

    Any ideas what could be causing the problem?
    Thanks!

    https://wordpress.org/plugins/jetpack/

Viewing 1 replies (of 1 total)
  • Thread Starter ken524

    (@ken524)

    I got the recommended code to work by building and installing it as a Plugin.
    Now my question is: why does the code work as a plugin but not as part of my functions.php?

Viewing 1 replies (of 1 total)
  • The topic ‘Trouble restricting post category on JetPack Mobile home page’ is closed to new replies.