Custom rewrite rule for hierarchical custom post type

You’re pretty close. Your rewrite rule is using the wrong query var, pagename should be just name. Here’s a version that works for me on a fresh 4.4.1 install and twentysixteen theme- function bvt_product_init() { $args = array( ‘label’ => __( ‘Product’, ‘domain’ ), ‘description’ => __( ‘Company products’, ‘domain’ ), ‘supports’ => array( ‘title’, … Read more

How to have extra permalink for posts

You can always use the post ID to link to a page, like this: http://yourdomain.tld/?p=1234 You can find out the Post ID right from the post overview screen. If you hover over the “Edit” or “Delete” link, you can see that the URL has a parameter post=. The number behind that is your page ID. … Read more

How to stop WordPress from removing & from URL?

Here’s the why part: This part of the redirect_canonical() is removing the leading & in the redirect query part: // tack on any additional query vars $redirect[‘query’] = preg_replace( ‘#^\??&*?#’, ”, $redirect[‘query’] ); Example: example.tld/?&a=1&b=2&c=3 is redirected to example.tld/?a=1&b=2&c=3 If you must have the leading & you might try to adjust it through the redirect_canonical … Read more

Pagination Issue – /page/2 404

Pieter was correct. It was messing up due to the custom loop I was running on the archive page. I removed the custom loop, and then adjusted the arguments with pre_get_posts. The strange thing was that, to test if it was this issue, running a custom loop on an archive page was the issue, I … Read more

Server Move: All pages leading home

Your proxy is rewriting everything to index.php, which means that the backend never sees the original URI. The proxy should be transparent, like this: server { listen 80; server_name example.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8080; } }

WordPress add_rewrite_rule() cannot visit lower url levels

I fixed my problem as follows: // Adds rewrite rules for shop post type function gtp_add_shop_rewrite_rules() { add_rewrite_rule( ‘^shop/([^/]*)/([^/]*)/([^/]*)$’, ‘index.php?shop-category=$matches[1]&width=$matches[2]&height=$matches[3]’, ‘top’ ); add_rewrite_rule( ‘^shop/([^/]*)/([^/]*)$’, ‘index.php?shop-category=$matches[1]&width=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘^shop/([^/]*)$’, ‘index.php?shop-category=$matches[1]’, ‘top’ ); } add_action(‘init’, ‘gtp_add_shop_rewrite_rules’, 10, 0);

Custom Post type and permalink settings

You can use the rewrite parameter to disable the front portion of the URLs (/academy/ in your case) for custom post types. function create_posttypes() { $labels1 = array( ‘name’ => __( ‘Definitions’ ), ‘singular_name’ => __( ‘Definition’ ), ‘all_items’ => __( ‘All Definitions’ ), ‘view_item’ => __( ‘View Definition’ ), ‘add_new_item’ => __( ‘Add New … Read more

Add archive slug to default post post type

Using the permalink settings to configure your post permalinks, then modifying the author permalinks seems like the way to go. I set up the permalink rules like this: /post/%postname%/ Then used this code to modify the author permalinks (source): // change base of author pages- need to save permalinks to take effect function wpse82004_change_author_permalink(){ global … Read more

Custom Permalink

The custom rule you are trying doesn’t meet the criteria. Here’s a nifty online .htaccess tester tool to see to check rewrite logic. Use the follow RewriteRule instead: RewriteCond %{QUERY_STRING} (^|&)name=(.*) RewriteRule ^(.*)$ /profile/%2/? [R=301,L] Be sure to replace ^example\.com$ on the first line with your actual domain. You can also embed it in the … Read more