WordPress function url_to_postid not working with Anspress

With the Anspress theme/plugin, using the WordPress native function url_to_postid() on a question permalink returns the page ID of the base page. For example,

would return the page ID of the /questions page.

To get the WP question ID of this-is-the-question, use the following:

(using get_post_types() instead of ‘questions’ allows the call to work even with permalinks of non-question contents.)

2 thoughts on “WordPress function url_to_postid not working with Anspress

  1. i had the exact same issue on my site with url_to_postid, spent several hours trying to fix it. Your solution here works flawlessly for me. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *