Load images with http urls inside https post

It’s a fairly common issue when you update your WordPress site’s URL form HTTP to HTTPS or if you are migrating to a new domain. While a partial solution is to update your WordPress’ home and site URL in your settings: That doesn’t mean that the new URL structure in your posts will be fixed. … Read more

How to check if feed URL was requested?

You have not specified exactly when your code runs but you can hook into “request” to check the requested page: add_filter( ‘request’, function( $request ){ if( isset( $request[‘feed’] ) ){ //This is a feed request } return $request; }); When the requested page is a feed $request, which is an array of query variables, will … Read more

Get taxonomy slug from url

I think you are looking for get_query_var $term_slug = get_query_var( ‘term’ ); $taxonomyName = get_query_var( ‘taxonomy’ ); $current_term = get_term_by( ‘slug’, $term_slug, $taxonomyName );

Removing hierarchical pages in the permalink

I’d be curious if someone can find a better solution to this. Here’s what I came up with: function wpse_91821_flatten_page_paths( $wp ) { if ( false !== strpos( $wp->matched_query, ‘pagename=” ) && isset( $wp->query_vars[“pagename’] ) && $wp->query_vars[‘pagename’] && false === strpos( $wp->query_vars[‘pagename’], “https://wordpress.stackexchange.com/” ) ) { if ( !get_page_by_path( $wp->query_vars[‘pagename’] ) ) { $page = … Read more

Rewrite rule page url with category

Just of the top of my head, something along this way might work: function wpse178647_rewrite() { add_rewrite_rule( ‘^([^/]+)/([^/]+)/?$’, ” ‘index.php?category_name=$matches[1]&pagename=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘wpse178647_rewrite’ ); Completely and utterly untested.

Clash of the rewrites

Your best option is to register neighborhoods as a custom taxonomy and use that instead of categories. In your theme’s functions.php file, you just need to add: function neighborhoods_init() { // create a new taxonomy register_taxonomy( ‘neighborhoods’, ‘post’, array( ‘label’ => __( ‘Neighborhoods’ ), ‘hierarchical’ => true ) ); } add_action( ‘init’, ‘neighborhoods_init’ ); Next, … Read more