(My issue is not that described in 'post_type_link' filter not working. In that instance Rizwan was attempting to use post_type_link to filter posts, which are instead handled by post_link.)
In my case I'm trying to use post_type_link on a custom post type created by the Liquid Messages plugin. The post type is 'gc-sermons' and my code is as follows:
function lqd_message_link( $url, $post ) {
if ( get_post_type( $post ) == 'gc-sermons' && isset( $wp_query->query_vars['messages-app-view'] ) ) {
return add_query_arg( $_GET, $url );
}
return $url;
}
add_filter( 'post_type_link', 'lqd_message_link', 10, 2 );
If you go to a sermon series page like the below:
https://liquidchurch.com/sermon-series/divine-direction/messages-app-view/
And then mouse over one of the messages you see the link URL is:
https://liquidchurch.com/message/step-by-step
Whereas I'm looking for it to be:
https://liquidchurch.com/message/step-by-step/messages-app-view/
Any ideas?
Note: The CPT (gc-sermons) is set during its registration with ep_mask as EP_ALL.
add_query_arg
here? What the filter returns should be the same as the filters from your other questions.