Add the .html extension to custom post types

Lets take these functions and paraphrase them into english, then put them in the order they’re ran. I’m going to deliberately avoid using PHP in this answer, but a basic understanding of PHP will be necessary: When the `post_type_link` filter runs: // the add_action calls run: `wpa_course_post_link` as it has priority 3 // function wpa_course_post_link(…. … Read more

Redirect user if it’s not logged in

I wouldn’t use htaccess for that. What I would do is make a ‘download page’ template and use it to ‘serve’ the files. By doing that, I can do a check with is_user_logged_in() Codex and redirect with wp_login_url() Codex Just do: if ( is_user_logged_in() ) : //file link else : wp_login_url(); endif; I think it’s … Read more

permalink for category pages and posts

There’s currently no way in core to get the current archive / category / tag / custom taxonomy URL. I have a patch waiting for that to be added right here. For now though, you could just use the code in the last patch on that ticket: <?php /* Get the current archive link * … Read more

How to make variables in URL look like the permalink structure?

The following two functions should point you in the right direction: function wpse49393_query_vars($query_vars) { $query_vars[] = ‘myvar’; return $query_vars; } add_filter(‘query_vars’, ‘wpse49393_query_vars’); function wpse49393_rewrite_rules_array($rewrite_rules) { $rewrite_rules[‘path/to/page/([^/]+)/?$’] = ‘index.php?pagename=path/to/page&myvar=$matches[1]’; return $rewrite_rules; } add_filter(‘rewrite_rules_array’, ‘wpse49393_rewrite_rules_array’); I would give credit where it is due, but I cannot remember where I originally found this code. I just pulled this … Read more