How to redirect a query string to a “virtual” subdirectory
How to redirect a query string to a “virtual” subdirectory
How to redirect a query string to a “virtual” subdirectory
The simplest way is done right in the post editor, you can use the button that is second in from the right side, of the editor toolbar, to insert a read more link at a certain point in your post. WordPress will display a shortened post with a read more link when the post is … Read more
Here is my current code: function hm_base_date_query_vars($vars) { $vars[] = ‘base_date’; return $vars; } add_filter(‘query_vars’, ‘hm_base_date_query_vars’); function hm_base_date_rewrite_rule() { add_rewrite_rule( ‘^my-calendar/([^/]*)/?’, ‘index.php?pagename=my-calendar&base_date=$matches[1]’, ‘top’ ); } add_action(‘init’, ‘hm_base_date_rewrite_rule’, 10, 0); $base_date_test = get_query_var(‘base_date’); on the url example.com/my-calendar/foo my var $base_date_test returns null Maybe someone can help me. Thanks. // Edit: It works. I tried to call … Read more
You can filter request and unset m there, which will remove it from the query. This is a simple example that will remove it in all cases, you probably want to narrow the check down with something else, like checking if pagename is also set: function wpd_request_filter( $request ){ if( isset( $request[‘m’] ) ){ unset( … Read more
I would think that .com/genre/comedy is actually picked up by the second rule since it matches that as well, and because it is added first I think it takes precedence. You could try to swap the order, so it goes 3, 4, 1, 2. For production, you might want to remove flush_rewrite_rules();, I believe it’s … Read more
Own query vars are not displayed
WP CLI – Pass Query / URL Variable to Cron?
SOLUTION My solution was change to use http://website.com/page-name/page/1/ and http://website.com/page-name/page/2/. And when I get query_var, I decrease it and check if it is less than zero, I return it to zero. I had to use this solution because when I pass /page/1/ or when I do not pass anything, my paged returns me a zero … Read more
I think I cracked it actually! Used this snippet: <?php $custom_terms = get_terms(‘topic’); foreach($custom_terms as $custom_term) { wp_reset_query(); $args = array(‘post_type’ => ‘episodes’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘topic’, ‘field’ => ‘slug’, ‘terms’ => $custom_term->slug, ), ), ); $loop = new WP_Query($args); if($loop->have_posts()) { echo ‘<h2>’.$custom_term->name.'</h2>’; } } ?>
CPT year wise archive based on custom date Field