How can I get the privacy policy page?

WordPress stores the page id for the privacy policy page in the options table. To get the value, you can use: $privacy_policy_page = get_option( ‘wp_page_for_privacy_policy’ ); if( $privacy_policy_page ) { $permalink = esc_url( get_permalink( $privacy_policy_page ) ); } The $privacy_policy_page variable holds the ID of the privacy policy page.

Get page permalink without wpurl

There’s nothing built in to return the bit you want but it should be as easy as using the home_url() function and removing it’s output from the full url eg: function get_relative_permalink( $url ) { return str_replace( home_url(), “”, $url ); }

Nested custom post types with permalinks

If you want to keep ‘authors’ as the base slug in the permalinks, i.e. example.com/authors/stephen-king/ for the ‘authors’ CPT, example.com/authors/stephen-king/the-shining/ for the ‘books’ CPT and example.com/authors/stephen-king/the-shining/chapter-3/ for the ‘chapters’ CPT, WordPress will think pretty much everything is an ‘authors’ post or a hierarchical child of an ‘authors’ post and, since that is not the case, … Read more

Get current URL (permalink) without /page/{pagenum}/

You can get the current URL through home_url( $wp->request ). Try the example below: global $wp; // get current url with query string. $current_url = home_url( $wp->request ); // get the position where ‘/page.. ‘ text start. $pos = strpos($current_url , ‘/page’); // remove string from the specific postion $finalurl = substr($current_url,0,$pos); echo $finalurl;

WordPress matching URLs with trailing tildes

Let’s go simple If I understand OP well, your problem is that urls containing a tilde are matched at all. All other answers focus on the fact that sanitization for query strips out some characters before perform the query, however one should be capable to prevent a rewrite rule to don’t match under some circumstances. … Read more

Shouldn’t this be easy?! Custom post type/custom taxonomy permalink

Follow the advice on this question as you did already, but add this to your code: add_action( ‘generate_rewrite_rules’, ‘fix_literature_category_pagination’ ); function fix_literature_category_pagination( $wp_rewrite ) { unset($wp_rewrite->rules[‘literature/([^/]+)/page/?([0-9]{1,})/?$’]); $wp_rewrite->rules = array( ‘literature/?$’ => $wp_rewrite->index . ‘?post_type=literature’, ‘literature/page/?([0-9]{1,})/?$’ => $wp_rewrite->index . ‘?post_type=literature&paged=’ . $wp_rewrite->preg_index( 1 ), ‘literature/([^/]+)/page/?([0-9]{1,})/?$’ => $wp_rewrite->index . ‘?literature_category=’ . $wp_rewrite->preg_index( 1 ) . ‘&paged=’ . … Read more