• Resolved asadowski10

    (@asadowski10)


    Hey team,

    In this file https://plugins.trac.ww.wp.xz.cn/browser/wordpress-seo/trunk/inc/sitemaps/class-post-type-sitemap-provider.php#L615 when you call get_permalink($post);

    $post is not a WP_Post or and ID but your Stdclass.

    In the function get_permalink() the final return has a filter :

    /**
    * Filters the permalink for a post.
    *
    * Only applies to posts with post_type of ‘post’.
    *
    * @since 1.5.0
    *
    * @param string $permalink The post’s permalink.
    * @param WP_Post $post The post in question.
    * @param bool $leavename Whether to keep the post name.
    */
    apply_filters( ‘post_link’, $permalink, $post, $leavename );

    If any plugins or custom code hook ‘post_link’ after WordPress SEO it can generate a fatal error.

    Could you modify your code to put an ID or an WP_Post instance ?

    Best,

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thanks for bringing this to our attention. While we are not sure whether this is something intentional or a bug, we’d love to investigate this further as well. So, if you have a spare moment to share with us, please do feel free to submit a proper bug or enhancement report directly at our GitHub development repository so our development team can look into this further for you.

    Thread Starter asadowski10

    (@asadowski10)

    It isn’t real issue. Function get_permalink uses function get_post which returns WP_Post object (converted from stdClass). So, the filter post_link contains correct object. You can see:

    The class WPSEO_Post_Type_Sitemap_Provider uses custom SQL query (to speedup process) on same way how it’s done in WP core.

    I’m Yoast SEO contributor and I’ve a lot of experience related to sitemaps. I’ve created many PRs and customizations. I never experienced this kind of issue related to sitemaps (but there were issues in other parts).

    UPDATE: It could be possible in some cases for built-in post types (page or post).

    • This reply was modified 5 years, 5 months ago by Saša.

    We are going ahead and marking this issue as resolved due to inactivity. If you require any further assistance please create a new issue.

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

The topic ‘Error param on get_permalink()’ is closed to new replies.