Custom Post Types Not Showing on Mobile Theme at all

Posted in: Newspaper
Post count: 45

Hello I am in need of some assistance, I have the mobile theme plugin installed which I greatly like but I need all of my custom post types to display on it as well.

I have added this line to the mobile theme’s functions but no luck:

//post query
function my_post_queries( $query ) {
// not an admin page and is the main query
if (!is_admin() && $query->is_main_query()){
// query the home page
if(is_home()){
$query->set(‘post_type’, array(‘post’, ‘yt’, ‘wft’, ‘radio’));
}
}
}
add_action( ‘pre_get_posts’, ‘my_post_queries’ );

//add to theme cpt
function namespace_add_custom_types( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) {
$query->set( ‘post_type’, array(
‘post’, ‘nav_menu_item’, ‘post’, ‘yt’, ‘wft’, ‘podcast’, ‘external’, ‘radio’
));
return $query;
}
}
add_filter( ‘pre_get_posts’, ‘namespace_add_custom_types’ );

//add custom post types to main blog
add_action( ‘pre_get_posts’, ‘add_my_post_types_to_query’ );

function add_my_post_types_to_query( $query ) {
if ( is_home() && $query->is_main_query() )
$query->set( ‘post_type’, array( ‘post’, ‘yt’, ‘wft’, ‘podcast’, ‘external’, ‘radio’ ) );
return $query;
}

I hope someone can help!

Post count: 20688

Hi,

Unfortunately this is no easy task and there is no easy solution I can provide to make the mobile theme support custom post types. Maybe this feature will be added in future theme updates, but I could not say for sure when this will happen. If you would like to implement something like this, it would require proper coding knowledge and probably a lot of work.

Thanks

Post count: 45

Thanks for the reply, the code snip above actually worked a bit, I placed it in the mobile theme functions and everything works as far as I can tell, the only thing I can’t figure out is how to get it on the front page.

Thanks for the reply though! I hope you guys keep updating that mobile theme as it is fantastic!
Nate

Post count: 32

If you have Static Homepage, you can try (but it’s quite unofficial) to add this short code to the Mobile page editor (below your usual Desktop Visual editor):

[td_block_big_grid_mob_1 installed_post_types="your-post-type-name-here"]

This short code supports other module shortcode parameters (like offset, sorting), but not “limit” (it will be always 3 posts). But you can tweak it in the themes/Newspaper/mobile/includes/shortcodes/td_block_big_grid_mob_1.php file

find

const POST_LIMIT = 3;

and change the number to what you like.

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.