conditional statement for active permalinks

get_option( ‘permalink_structure’ ) is your friend. If you’re using the default it will be set as an empty string: if( get_option( ‘permalink_structure’ ) !== ” ) { // custom permalink enabled code } else { // no permalink }

Non latin post slug truncate

No, it is not entirely possible. WordPress is using Percent encoding to sanitise the slug. You could undo this, and it would deliver nonlatin characters, but the browser would immediately swap these out for percent encoded characters when you tried to visit the page. Wether your database will store these characters, and the table encoding … Read more

Rewrite rule for a query string

Try this code: function geotags_add_rewrite_rules($wp_rewrite_rules) { global $wp_rewrite; $rule_key = ‘%cityid%’; $url_pattern = ‘([^/]+)’; $query_string = ‘cityid=’; $wp_rewrite->add_rewrite_tag($rule_key, $url_pattern, $query_string); $url_structure = $wp_rewrite->root . “cityid/$rule_key/”; $rewrite_rules = $wp_rewrite->generate_rewrite_rules($url_structure); $wp_rewrite_rules = $rewrite_rules + $wp_rewrite_rules; return $wp_rewrite_rules; } add_filter(‘rewrite_rules_array’, ‘geotags_add_rewrite_rules’); function geotags_add_query_var($query_vars) { array_push($query_vars, ‘cityid’); return $query_vars; } add_filter(‘query_vars’,’geotags_add_query_var’); NOTE: Remember to save permalinks so your new … Read more

Why doesn’t a custom post type permalink ever hit index.php

Your Custom Post Type is using the single.php and (most likely) archive.php templates. A single CPT post looks for templates in this order: single-{post_type}.php – If the post type were product, WordPress would look for single-product.php single.php index.php Other CPT pages look for templates in this order: taxonomy-{taxonomy}-{slug}.php taxonomy-{taxonomy}.php – If the taxonomy were sometax, … Read more