godaddy-wordpress / coblocks

A suite of professional page building content blocks for the WordPress Gutenberg block editor.
https://wordpress.org/plugins/coblocks/
GNU General Public License v2.0
749 stars 146 forks source link

ISBAT Open graph tags from “The SEO Framework” not injected on custom post types #2093

Open gdandrija opened 3 years ago

gdandrija commented 3 years ago

Describe the bug:

CoBlocks is incompatible with The SEO Framework, this applies custom post types that use init hook with the priority of 10

To reproduce:

  1. Create a custom post type using init hook
  2. Add a sample post using the newly created custom post type
  3. Install The SEO Framework plugin(free plugin)
  4. Add OG meta tags to the created post
  5. Check OG: https://opengraphcheck.com/ -->

Expected behavior:

I should see of metadata inserted

Isolating the problem:

WordPress version:

5.8.1

Gutenberg version:

/

Temporary fix:

Insert the following code snippet to override the function priority set in /includes/class-block-patterns.php on line 33 add_action( 'init', array( $this, 'load_block_patterns' ), 15, 0 );

Issue and the fix initially submitted by user henjak on WordPress.org: https://wordpress.org/support/topic/open-graph-tags-from-the-seo-framework-not-injected-on-custom-post-types/

jonathanbardo commented 3 years ago

@gdandrija Thanks for reporting. I'm not sure I understand how this solve the problem. We are currently registering on init a custom post type on the standard priority which seems to be standard practice. @jrtashjian might provide more input here. Maybe that custom post type isn't meant to be public at all and that is what's missing here.

henjak commented 2 years ago

@jonathanbardo The standard priority works great when registering the post type, but the issue is the load_block_patterns-method.

I would say that load_block_patterns()-method should have a priority higher than register_post_type()-method to make sure it's actually loaded after the post types is registered. Sure, it loads after your registered post type, coblocks_pattern, but not other registered post types.

The following is true & tested: Registered post types with a priority of 10 (default) loads after the load_block_patterns()-method. If I set 9 as the priority for my registered custom post type the OG tags is injected correctly.

Hope that makes sense. Thanks.

shrff commented 2 years ago

We still have this issue when using the SEO Framework and Coblocks together on a client site. We used to be able to change the priority of our own custom post types and this fixed it but we're now having to edit the plugin using the temporary fix above.