• Hi,

    Thanks for solving my previous queries about the Food Menu post type included with Jetpack. I have one more πŸ˜‰

    When I’m trying to view the single post page of the Food Menu CPT item, also the menu-group-header markup is being outputted together with wrapping it all in the section. Is it possible to get rid of this wrapper and group name (and description) output on singular pages? It’s not necessary to output it there.

    I thought it wouldn’t be necessary to output the singular post page of this CPT, but what if somebody want to display a CPT’s post excerpt on a Food Menu page (template) and a whole description (maybe a recipe) on a singular CPT page? That’s why I would like to get rid of the above.

    Thanks!

    Oliver

    https://ww.wp.xz.cn/plugins/jetpack/

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

    (@jeherve)

    Jetpack Mechanic πŸš€

    I’m afraid that won’t be possible. You would be able to remove the whole markup on specific pages by removing the filter (ref) on those pages, it would also remove the rest of the markup.

    You could, however, hide it with CSS:

    .single-nova_menu_item .menu-group-header {
    	display: none;
    }
    Thread Starter WebMan Design | Oliver Juhas

    (@webmandesign)

    Hi Jeremy,

    Thanks for the input. Yes, that is actually what I meant, to remove the filter. However, can you point me in the right direction of doing this when a class method is used for the filter?

    Thanks!

    Oliver

    Thread Starter WebMan Design | Oliver Juhas

    (@webmandesign)

    I’m trying to remove the filter, however, I’m not able to do so. According to http://codex.ww.wp.xz.cn/Function_Reference/remove_action#Example

    I’ve tried to look for the global that holds the Nova_Restaurant class, but I can’t see one.

    Also, the

    remove_action( 'loop_start', array( 'Nova_Restaurant', 'start_menu_item_loop' ) );

    does nothing…

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic πŸš€

    You’d have to remove setup_menu_item_loop_markup__in_filter entirely. But like I said, that would all the markup, everywhere, not just menu-group-header. Is that what you want to achieve?

    If you’re trying to remove the markup because of the bug you uncovered yesterday (#), I’d suggest giving it a day or 2, we should be able to get this fixed πŸ™‚

    Thread Starter WebMan Design | Oliver Juhas

    (@webmandesign)

    Hi Jeremy,

    No, the reason is not for the bug I’ve mentioned before.

    I just would like to remove the markup (the whole header and section wrappers) around the single Food Menu post page.

    Yes, I also tried to remove the setup_menu_item_loop_markup__in_filter with no luck, though.

    I would like to remove this filter conditionally, on single Food Menu post pages only. When you say this would remove the markup everywhere, what do you mean by that? The single Food Menu post wouldn’t output? I really just want to remove the markup on singular CPT page.

    Regards,

    Oliver

    Thread Starter WebMan Design | Oliver Juhas

    (@webmandesign)

    You know, I’ve tried this now, and it would work perfectly:

    1. I’ve edited Jetpack’s https://github.com/Automattic/jetpack/blob/3.2.1/modules/custom-post-types/nova.php#L1028 line to:
      if ( apply_filters( 'jetpack_menu_item_loop_markup_enable', true ) ) {
      	add_action( 'loop_start', array( $this, 'start_menu_item_loop' ) );
      }
      
    2. Then, I’ve just used this in my theme’s functions:
      /**
       * Disable Jetpack's menu markup on singular menu item page
       */
      if ( ! function_exists( 'my_disable_menu_markup' ) ) {
      	function my_disable_menu_markup( $bool ) {
      		if ( is_singular( 'nova_menu_item' ) ) {
      			$bool = false;
      		}
      
      		return $bool;
      	}
      } // /my_disable_menu_markup
      
      add_filter( 'jetpack_menu_item_loop_markup_enable', 'my_disable_menu_markup' );
      

      And it worked perfectly fine.

    Could something like this be implemented in the plugin’s CPT?

    Thanks.

    Oliver

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic πŸš€

    Try something like this to remove the marktup:

    function jeherve_remove_nova_markup() {
            if ( class_exists( 'Nova_Restaurant' ) && is_singular( 'nova_menu_item' ) ) {
                    remove_filter( 'template_include', array( Nova_Restaurant::init(), 'setup_menu_item_loop_markup__in_filter' ) );
            }
    }
    add_action( 'wp', 'jeherve_remove_nova_markup' );
    Thread Starter WebMan Design | Oliver Juhas

    (@webmandesign)

    Thank you Jeremy! Works perfectly.
    Thank you for teaching me something new! πŸ˜‰

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

The topic ‘Nova.php custom post type single post view’ is closed to new replies.