• As noted in this post, I was using a combination of The Events Calendar and WPtouch plugins at //https://pvwd080814wmaapp.pioneervalleywebdesign.com/events/
    I was having trouble with the Events Custom Post Type.

    I switched to JetPack Mobile Theme and that fixed the Events CPT issue, but broke the other custom post type, members. Below is what I am using in functions.php of a twenty eleven child theme:

    add_action( 'init', 'create_post_type' );
    function create_post_type() {
    register_post_type( 'members',
    			array(
    			'labels' => array(
    			'name' => __( 'Members' ),
    			'singular_name' => __( 'Member' )
    			),
    			'public' => true,
    			'has_archive' => true,
    			'show_ui' => true,
    			'show_in_nav_menus' => true,
    			'menu_position' => 5,
    			'rewrite' => array(
    				'slug' => 'members',
    				'with_front' => FALSE,
    			),
    			'exclude_from_search' => FALSE,
    			'publicly_queryable' => TRUE,
    			'supports' => array(
    					'title',
    					'editor',
    					'author',
    					'thumbnail',
    					'excerpt',
    					'trackbacks',
    					'comments',
    					'revisions',
    					'post-formats',
    	),
    	'taxonomies' => array('category', 'post_tag',),
    	'update_count_callback' => '_update_post_term_count'
    ));
    }
    
    add_filter('pre_get_posts', 'query_post_type');
    function query_post_type($query) {
      if(is_category() || is_tag()) {
        $post_type = get_query_var('post_type');
    	if($post_type)
    	    $post_type = $post_type;
    	else
    	    $post_type = array('nav_menu_item','post','members','tribe-events','tribe-venue','tribe-organizer',);
        $query->set('post_type',$post_type);
    	return $query;
        }
    }

    On mobile, the members url takes you to the homepage and none of the taxonomies work, category or tag.

    Any thoughts?

    https://www.ads-software.com/plugins/jetpack/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Pioneer Web Design

    (@swansonphotos)

    I have deactivated Jetpack Mobile Theme, added in WordPress Responsive Menu, added a few @media rules to the Child Theme’s stylseheet and am done with this issue. Not sure why Twenty Eleven does not fork this plugin over to the theme. It works well and the only part of the TwentyEleven Theme I found not to be responsive is the menu.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Not sure why Twenty Eleven does not fork this plugin over to the theme.

    Instead of declaring custom post types in your theme, I’d suggest building a small plugin instead. Indeed, when you switch to another theme (like Jetpack’s Mobile Theme or WPTouch), you lose all the code that’s running on your desktop theme.

    If you move that code into a separate plugin, it will always run on your site, regardless of the theme you use.
    If you don’t feel comfortable building your own plugin, you can use a functionality plugin instead.

    Thread Starter Pioneer Web Design

    (@swansonphotos)

    Now all we need the Happiness Engineers here to do is to update ALL relevant posts, help articles, and the Codex to note such.

    Of course, the issue in NOT about switching themes, it is about about why it still does not work right in so many cases!@

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Now all we need the Happiness Engineers here to do is to update ALL relevant posts, help articles, and the Codex to note such.

    I recommend functionality plugins over theme modifications as much as I can, but I am afraid I have no control over the hundreds of tutorials out there explaining you how to create Custom Post Types.

    A general rule of thumb is to use plugins for everything that’s related to your site content, and your theme for design changes. Changing the style of a button can be done in your theme. Creating a new shortcode or a custom post type should be done in a plugin.

    the issue in NOT about switching themes, it is about about why it still does not work right in so many cases!@

    I’m not sure I understand. If you still experience issues, could you give me more details, or post a link to a page where I can see the issue?

    Thanks!

    Thread Starter Pioneer Web Design

    (@swansonphotos)

    Now all we need the Happiness Engineers here to do is to update ALL relevant posts, help articles, and the Codex to note such.

    That would be this forum and the Codex. Also:

    1. I did post a link. It was //https://pvwd080814wmaapp.pioneervalleywebdesign.com/events/ as read in OP.
    Now it is //https://wmaapp.org/events/ (sorry to not include live links but who wants a link on a forum 7 years later?)
    2. I understand your point re plugin v. theme, but when we cannot get the base functionality to work, how do we write a plugin?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    That would be this forum and the Codex.

    Feel free to edit the codex pages where you find problems: you’ll find edit links next to each section when logged in with your www.ads-software.com account.
    You can read more about it here:
    https://codex.www.ads-software.com/Codex:Contributing

    The good news is, the Custom Post Types page already seems to mention the risks of defining Custom Post Types in your theme instead of a plugin:
    https://codex.www.ads-software.com/Custom_Post_Types#A_word_about_custom_post_types_as_a_plugin

    We cannot edit forums threads, though. Only moderators and admins have that power, and they usually only delete or edit questionable content. You can read more about it here:
    https://codex.www.ads-software.com/Forum_Welcome#Deleting_.2F_Editing_Posts

    how do we write a plugin?

    You can check the codex to get started:
    https://codex.www.ads-software.com/Writing_a_Plugin

    There are also a few tutorials that should help:
    https://www.wpbeginner.com/wp-tutorials/how-to-create-a-wordpress-plugin/

    If you don’t feel comfortable creating your own plugin, you could use this plugin to create Custom Post Types on your site without having to tie them to your current theme.

    That will solve all the issues you will experience when switching to a different theme, either because you want to try a new main theme for your site, or because you want to use a plugin that switches your theme in some situations (like Jetpack’s Mobile Theme, WPTouch, or other mobile plugins).

    I hope this helps.

    Thread Starter Pioneer Web Design

    (@swansonphotos)

    WRONG:

    if(is_category() || is_tag()) {

    Will always works best as:

    RIGHT:

    if((is_category()) || (is_tag())) {

    Why? Two functions. This is HORRIBLY described both here and in almost every site related.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Post Types’ is closed to new replies.