Rewrite custom post type rss feed links

Put this in a plugin or functions.php: function feed_rewrite( $wp_rewrite ) { $feed_rules = array( ‘feed/portfolio’ => ‘index.php?post_type=post&feed=rss2’ ); $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; } // refresh/flush permalinks in the dashboard if this is changed in any way add_filter( ‘generate_rewrite_rules’, ‘feed_rewrite’ ); When you’ve done that, go to the permalinks page and resave to flush … Read more

Relative URLs and hide /wp-content/themes/

The easiest way to move your theme folder is only via constant; include the wp-content folder. You can set a constant for the plugin folder and wp-content folder. Then is your plugins and themes in separete url, also in the include in the source of the frontend. like this example for my dev installs: define( … Read more

How to make a category page the blog home page?

Update Eliminating all of the other solutions, there is at least one remaining: template_redirect: function wpse121308_redirect_homepage() { // Check for blog posts index // NOT site front page, // which would be is_front_page() if ( is_home() ) { wp_redirect( get_category_link( $id ) ); exit(); } } add_action( ‘template_redirect’, ‘wpse121308_redirect_homepage’ ); You will need to pass … Read more

I want to create a custom slug in WordPress and output JSON. How do I do this?

You can use pre_get_posts as suggested but simply check the global $wp object for the request url.. like so: add_action( ‘pre_get_posts’, function ($query ){ global $wp; if ( !is_admin() && $query->is_main_query() ) { if ($wp->request == ‘cats’){ header(‘Content-Type: application/json’); $cats = array(‘Hobbes’, ‘Simba’, ‘Grumpy Cat’); echo json_encode($cats); exit; } } }); (PHP 5.3+ in this … Read more

Rewrite URL – how to do a SEO-friendly Unicode custom URL?

If you write your post titles in Bānglā but set the post slug in English, you can do this: function wpse117090_pre_post_link( $permalink, $post ) { return str_replace( ‘%posttitle%’, sanitize_title( $post->post_title ), $permalink ); } add_filter( ‘pre_post_link’, ‘wpse117090_pre_post_link’, 10, 2 ); Then change your permalink structure to, for example, /%postname%/%posttitle%/ (Please note that the above code … Read more