RankMath with Custom Post Types PHP notice

#160055
  • Resolved Jp
    Rank Math free

    Hello,

    nothing but praise for RankMath, but it apparently has an issue with my Custom Post Types – when I try to add a new custom post, it throws these notices at me:

    Trying to get property 'name' of non-object in /home/vagrant/code/hkosig/wp-content/plugins/seo-by-rank-math/includes/admin/metabox/class-post-screen.php on line 426

    Trying to get property 'labels' of non-object in /home/vagrant/code/hkosig/wp-content/plugins/seo-by-rank-math/includes/admin/metabox/class-post-screen.php on line 426

    Trying to get property 'singular_name' of non-object in /home/vagrant/code/hkosig/wp-content/plugins/seo-by-rank-math/includes/admin/metabox/class-post-screen.php on line 426

    This is how I registered my CPTs:


    public function hko_cpt() {
    register_post_type(
    'product',
    [
    'labels' => [
    'name' => __( 'Proizvodi i usluge', 'hko-cpt' ),
    'singular_name' => __( 'Proizvod i usluga', 'hko-cpt' ),
    ],
    'public' => true,
    'has_archive' => false,
    'show_in_rest' => true,
    'rewrite' => [
    'slug' => 'proizvodi-i-usluge',
    ],
    'supports' => [ 'title', 'custom-fields', 'editor', 'excerpt', 'thumbnail' ],
    'menu_position' => 5,
    'menu_icon' => 'dashicons-hammer',
    ]
    );
    }

    Obviously it’s not a fatal error so it doesn’t break the site, but I prefer bug-free coding, so I’d really like to resolve this. ๐Ÿ˜€
    Hopefully you could steer me in the right direction?
    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting the support and sorry for any inconvenience that might have been caused due to that.

    Assuming you are using the latest version of all the plugins and the themes (please update if not yet), it would seem like a conflict with one of the plugins or the theme you are using.

    To determine that, please follow this troubleshooting guide:
    https://rankmath.com/kb/check-plugin-conflicts/

    Only the site admin would know and your users won’t be affected by this troubleshooting.

    If the issue persists, please record a video screencast using a tool like Loom showing the troubleshooting and edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    Please do take a complete backup of your website before sharing the information with us.

    We really look forward to helping you.

    Jp
    Rank Math free

    Hello, thank you for the quick reply! I did what the troubleshooting instructions proposed and… eh, the issue starts appearing when I enable RankMath, no other plugins or theme are causing the conflict. However, I did register my CPT through a plugin (which obviously needs to be active in order for CPTs to work) instead of doing it in the functions.php file or somewhere else within the theme, could that be an issue?

    Hello,

    Thank you for the update.

    In this case, we might need to take a closer look at the settings to confirm that and investigate this issue. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section as per my colleague’s instructions above.

    Thank you, and we really look forward to helping you.

    Jp
    Rank Math free

    Hello,

    I’ve solved this in the meantime – the problem was the name of my CPT, I named it ‘product’ so maybe it was some sort of naming conflict with WooCommerce, who knows. Anyway, I renamed the CPT to (prefix)_product and the notice went away, so there you have it. ๐Ÿ˜€

    Best,

    Jakov

    Prabhat
    Rank Math agency

    Hello,

    Weโ€™re glad that you got that sorted.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘RankMath with Custom Post Types PHP notice’ is closed to new replies.