• Resolved GATEKeeper

    (@gatekeeper)


    We’ve enabled the mobile theme for one site, but when visiting the home page, a query at the top of the page is being ignored and won’t display.

    What could be causing this?

    Here’s the code:

    <?php if ( is_front_page() ) {
    	$upcoming = new WP_Query();
    	$upcoming->query( array(
    		'post_type'=> 'tribe_events',
    		'posts_per_page' => 1
    		)
    	);
    
    	if ($upcoming->have_posts()) :
    		while ($upcoming->have_posts()) :
    			$upcoming->the_post();
    			?>

    I tried taking out the if statement, so it appeared everywhere, but it still would not appear.

    http://wordpress.org/plugins/jetpack/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    I assume you’ve added this query to your desktop theme? If so, it won’t be applied to other themes like Jetpack’s Mobile Theme.

    If you want to add a custom query that would be applied to all your themes, you would need to add this query via a plugin that would hook into a function present in all themes.

    I hope this helps.

    Thread Starter GATEKeeper

    (@gatekeeper)

    Just to be clear, the Mobile Theme is taking all the rest of the code from that page, but it ignores queries, I guess?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    The Mobile Theme won’t take any elements from your desktop theme. It’s a different theme, and cannot get any information from another theme on your site.

    If you want an element like a custom template to be used on 2 different themes (like your desktop theme and a mobile theme like Jetpack’s), you’ll need to include that element in a plugin, since plugins are loaded regardless of your theme.

    You can use the template_redirect function to load a custom template via a plugin:
    http://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect

    Thread Starter GATEKeeper

    (@gatekeeper)

    Okay, I understand now. The oddity is that the layout/design is almost exactly like the desktop, but it’s a coincidence, it seems, and it’s also because the majority of our style is included within the page content.

    Thanks for the extra information.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Query ignored on home page with Jetpack mobile theme’ is closed to new replies.