How can I get custom post types to recognize pretty permalink variables?

Building Custom URLs in WordPress discusses how to use Pretty Permalinks to display posts using additional parameters. Jump to the section on Custom Query Vars. That’s where your situation begins to be addressed directly. In particular, you may want to use the example using ‘pre_get_posts‘ to retrieve parameters and adjust the WP_Query using a meta_query, … Read more

How to allow WordPress to recognize a custom URL segment after a product URL and use a custom template?

Looks like all I needed to do was put the template_include filter inside of the init action. Source: https://stackoverflow.com/a/50037707/5749974 add_action( ‘init’, function () { $product_base = ltrim( get_option( ‘woocommerce_permalinks’ )[ ‘product_base’ ], “https://wordpress.stackexchange.com/” ); add_rewrite_rule( “{$product_base}/([^/]+)/test”, ‘index.php?product=$matches[1]&test=1’, ‘top’ ); add_filter( ‘template_include’, function( $template ) { if ( get_query_var( ‘test’ ) ) { $template = get_stylesheet_directory() … Read more

Add pagination to a template loaded by query variable

After a bit of digging over the weekend, I found the solution and indeed, it is a rewrite rule with the paged variable added add_rewrite_rule(‘collection/men/page/([^/]+)/?$’,’index.php?post_type=collection&men=yes&paged=$matches[1]’,’top’); Pagination now works in the custom template loaded by query variable. i.e. localhost/sample-site/collection/men/page/2 loads the next page instead of a 404 error

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)