URL Rewrite and Archive Template Files – Post Type vs. Taxonomy

I handled this with a pre_get_posts hook (thanks, @Milo), passing in the URL part that corresponds to the slug I need. Hope this helps someone down the road. Improvements are welcome. Thanks. function filter_team_news_archives_by_sport_taxonomy($query) { if (is_post_type_archive(‘team-news’) && $query->is_main_query()){ // Get $sport_slug from URL — https://stackoverflow.com/a/36002190/4107296 $url = (isset($_SERVER[‘HTTPS’]) ? “https” : “http”) . “://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”; … Read more

Broken page redirect

I found solution – I needed to run flush_rules() method at least once to clean cache. //Ensure the $wp_rewrite global is loaded global $wp_rewrite; //Call flush_rules() as a method of the $wp_rewrite object $wp_rewrite->flush_rules( false );

url rewriting on custom post type

I just realized i used different kind of rewriting which didn’t require @Jacob’s codes (using add_rewrite_endpoint) add_action(‘init’, ‘wpse42279_add_endpoints’); function wpse42279_add_endpoints() { add_rewrite_endpoint(‘play’, EP_PERMALINK); } And then i used this conditionals on the single page: global $post; $pid = $post->ID; $var = get_query_var( ‘play’ ); if( !empty($var) and $var == $pid) : // do stuff endif; … Read more

How to use a capture from a rewrite rule inside a php file (like single.php)?

Nicolais Tip got me on the right track; Here is the working code: // add a query_var first add_filter(“query_vars”, function($vars) { $vars[] = “myTheme_podcast_time”; return $vars; }); add_filter(“rewrite_rules_array”, function($rules) { $newRules = array(); $newRules[“(.*)/time/([\d|\:]+)s?$”] = ‘index.php?name=$matches[1]&myTheme_podcast_time=$matches[2]’; $merged = array_merge($newRules, $rules); return $merged; }); And then in single.php: $time = get_query_var(“myTheme_podcast_time”); // do stuff

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