Support » Plugin: Yoast SEO » og:url filter for paginated posts

  • Resolved Forest_Parks

    (@forest_parks)


    I’m trying to ensure that the URL in og:url for paginated posts is always the first post. So, if someone shares from page 3 it will always share the top level URL (or at least the og:url will be the top level with no /2/ in it).

    I found this function

    function md_no_paging_in_og( $url ) {
    	if ( is_singular( array( 'post', 'page' ) ) ) {
    		$url = WPSEO_Frontend::get_instance()->canonical( false, true );
    	}
    	return $url;
    };
    add_filter( 'wpseo_opengraph_url', 'md_no_paging_in_og' );

    But it’s not working. Any ideas how I can do this?

  • The topic ‘og:url filter for paginated posts’ is closed to new replies.