• Resolved actonmike

    (@actonmike)


    First off, THANK YOU for the very detailed documentation. Being a beginner this makes a HUGE difference.

    Next, I searched herein and Googled, and tried everything I can find. If I have missed something obvious here please forgive me and just point me to the correct docs.

    Using the Jetpack Mobile Theme. Jetpack is fully updated. I inserted the jetpackme_modify_main_query code as defined on https://jetpack.com/2014/02/26/exclude-a-category-from-mobile-theme/ substituting the proper category ID.

    This is very similar to another filter I inserted into functions.php of my child theme to remove all posts of this same category from the desktop homepage. I thought that original filter would also change the Jetpack Mobile Theme, but it didn’t so I found your own code to do this on mobile too.

    However, with the Jetpack code inserted into the functions.php of the child theme the desired effect is not realized. Tested on an iPhone and with the Chrome tools on a desktop pretending to be an iPhone 6 Plus.

    The main theme is WooRockets WR-Elite which apparently is now unsupported (and funky). Decided to use the Jetpack Mobile Theme because mobile on WR-Elite is all messed up.

    Anything you can suggest or point me toward so that I can figure this out would be most appreciated. Hopefully it’s something stupid and we can all point and laugh. Here is the contents of the child theme functions.php file:

    <?php
    // Exit if accessed directly
    if ( !defined( ‘ABSPATH’ ) ) exit;

    // BEGIN ENQUEUE PARENT ACTION
    // AUTO GENERATED – Do not modify or remove comment markers above or below:

    if ( !function_exists( ‘child_theme_configurator_css’ ) ):
    function child_theme_configurator_css() {
    wp_enqueue_style( ‘chld_thm_cfg_child’, trailingslashit( get_stylesheet_directory_uri() ) . ‘style.css’, array( ‘owl-carousel’,’elite-main’,’elite-responsive’,’elite-pagebuilder’ ) );
    }
    endif;
    add_action( ‘wp_enqueue_scripts’, ‘child_theme_configurator_css’ );

    // END ENQUEUE PARENT ACTION

    //=================================================================================================================
    // Mike Acton added to eliminate all posts of Category Press Release from displaying on homepage 9-29-16
    //=================================================================================================================
    function exclude_category($query) {
    if ( $query->is_home() ) {
    $query->set( ‘cat’, ‘-35’ ); //The number 35 corresponds to the ID=35 of the Press Release category
    }
    return $query;
    }
    add_filter( ‘pre_get_posts’, ‘exclude_category’ );
    //=================================================================================================================
    // End added code by Mike Acton
    //=================================================================================================================

    //=================================================================================================================
    // Mike Acton added to disable Jetpack Related Posts on The Events Calendar single event posts 9-29-16
    //=================================================================================================================
    function jetpackme_no_related_posts( $options ) {
    if ( is_singular( ‘tribe_events’ ) ) {
    $options[‘enabled’] = false;
    }
    return $options;
    }
    add_filter( ‘jetpack_relatedposts_filter_options’, ‘jetpackme_no_related_posts’ );
    //=================================================================================================================
    // End added code by Mike Acton
    //=================================================================================================================

    //=================================================================================================================
    // Mike Acton added to disable Jetpack Mobile Theme posting Press Releases 10-3-16
    // From https://jetpack.com/2014/02/26/exclude-a-category-from-mobile-theme/
    //=================================================================================================================
    // Check if we are on mobile
    function jetpackme_is_mobile() {

    // Are Jetpack Mobile functions available?
    if ( ! function_exists( ‘jetpack_is_mobile’ ) )
    return false;

    // Is Mobile theme showing?
    if ( isset( $_COOKIE[‘akm_mobile’] ) && $_COOKIE[‘akm_mobile’] == ‘false’ )
    return false;

    return jetpack_is_mobile();
    }

    // Modify the main query on the home page for the mobile theme.
    function jetpackme_modify_main_query( $arg ) {
    if ( jetpackme_is_mobile() && is_home() ) {
    $arg -> set( ‘cat’, ‘-35’ );
    }
    }
    add_action( ‘pre_get_posts’, ‘jetpackme_modify_main_query’ );
    //=================================================================================================================
    // End added code by Mike Acton
    //=================================================================================================================

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter actonmike

    (@actonmike)

    Sorry, forgot to mention the site https://www.offroadspectator.com/

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    However, with the Jetpack code inserted into the functions.php of the child theme the desired effect is not realized.

    That’s to be expected. Jetpack’s Mobile Theme is a different theme, so any code that you’ve added to your desktop theme (parent theme or child theme) won’t run whenever you switch to another theme, like Jetpack’s Mobile Theme.

    If you want to customize the behaviour of the Mobile Theme via filters, you’ll need to add that code to a plugin, like this one, that will run regardless of the theme you’re using.

    I hope this helps!

    Thread Starter actonmike

    (@actonmike)

    Thank you so much Jeremy.

    So, then I just misunderstood the directions in the Jetpack Tips & Trick posts https://jetpack.com/2014/02/26/exclude-a-category-from-mobile-theme/ because it sounds like I’m supposed to add the code to my main theme “you can use the following code in your theme’s functions.php”. Although as you pointed out the mobile theme is unto itself.

    So last question and then I will leave you alone. Is there a separate functions.php for the Jetpack Mobile Theme and that is where I needed to add the code if I were to follow those directions verbosely?

    Thanks again!!!! I’m learning a lot.

    Mike

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    it sounds like I’m supposed to add the code to my main theme “you can use the following code in your theme’s functions.php”.

    Thanks for letting me know. I’ve updated that post to remove the reference to the theme’s functions.php file.

    Is there a separate functions.php for the Jetpack Mobile Theme and that is where I needed to add the code if I were to follow those directions verbosely?

    Since Jetpack’s Mobile Theme code is in the plugin files, I’d recommend against editing that code. Instead, you can place your code in a functionality plugin like this one:
    https://ww.wp.xz.cn/plugins/code-snippets/

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Mobile Theme Category Filter not working’ is closed to new replies.