• Resolved harrycustom

    (@harrycustom)


    Hi, I created a custom post type by hand directly in functions.php. In critical css conditional tags it is not detected, how can I do to achieve this?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    I *think* setting the CPT to public
    in the register_post_type args should result in the CPT being available harrycustom.

    hope this helps,
    frank

    Just a heads up, I have 'public' => true, in my register_post_type( 'mycustompost', $args ); but still no ao_metabox on mycustompost, Maybe the critical css condition though is totally different.

    • This reply was modified 3 years, 7 months ago by drazon. Reason: explanation
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    ah, so it does appear in critical CSS?

    as far as metabox; by default it only appears on posts/ pages, but you can use the autoptimize_filter_metabox_screens filter to add whatever post type you wish to the screens array πŸ™‚

    just checked…I confirm, setting public to false hides the custom post type from the critical css but if set to true then it is shown.

    Thanks for the filter Frank I will use it.

    Thread Starter harrycustom

    (@harrycustom)

    Ok, perfect, thank you so much!

    Thread Starter harrycustom

    (@harrycustom)

    I am sorry I’ve checked today but public is set as true, but I cannot see my CPT. πŸ™

    I have two custom post types on my site, in which I want to display the AO options:

    • course
    • llms_membership

    I have written this small function:

    function ao_add_metabox_lifterlms( $screens ) {
    	$screens = [ 'course', 'llms_membership' ] ;
    		return $screens;
    }
    add_filter( 'autoptimize_filter_metabox_screens', 'ao_add_metabox_lifterlms' );

    It works but could you Frank confirm it is the proper way of doing this?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I think you would override the default “screens” that way (for post & page), so I would rather do something like this;

    function ao_add_metabox_lifterlms( $screens ) {
      $screens[] = 'course';
      $screens[] = 'llms_membership';
      return $screens;
    }
    add_filter( 'autoptimize_filter_metabox_screens', 'ao_add_metabox_lifterlms' );

    hope this helps,
    frank

    Good point, it did override. I didn’t check post&pages edit screens after applying my code. Your code works like it should.

    Thank you

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’re welcome πŸ™‚

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

The topic ‘Custom Post Type Support’ is closed to new replies.