Remove some rewrite rules in wordpress

You can modify the global WP_Rewrite variable directly. add_action(‘init’, function(){ global $wp_rewrite; echo “<pre>”; var_dump($wp_rewrite); wp_die(); }); There are sevel properties you can adjust: $wp_rewrite->permalink_structure $wp_rewrite->use_trailing_slashes $wp_rewrite->author_base $wp_rewrite->search_base $wp_rewrite->comments_base $wp_rewrite->pagination_base $wp_rewrite->comments_pagination_base $wp_rewrite->feed_base $wp_rewrite->front $wp_rewrite->root $wp_rewrite->index $wp_rewrite->matches $wp_rewrite->rules $wp_rewrite->extra_rules $wp_rewrite->extra_rules_top $wp_rewrite->non_wp_rules $wp_rewrite->extra_permastructs $wp_rewrite->endpoints $wp_rewrite->use_verbose_rules $wp_rewrite->use_verbose_page_rules $wp_rewrite->rewritecode $wp_rewrite->rewritereplace $wp_rewrite->queryreplace $wp_rewrite->feeds And alternate removal functions: $wp_rewrite->remove_permastruct $wp_rewrite->remove_rewrite_tag

How can I include permalinks in this code?

You can eventually add ID in $sql, then it will be easier to use get_permalink function in the foreach : <?php global $wpdb; $sql = “SELECT ID, post_title, meta_value FROM $wpdb->posts a JOIN $wpdb->postmeta b ON a.ID = b.post_id WHERE a.post_type=”page” AND a.post_status=”publish” AND b.meta_key = ‘_wp_page_template’ ORDER BY a.post_title ASC “; $results = $wpdb->get_results( … Read more

Edit permalink for certain pages

I agree with @Milo it would be easiest to do it by having the Services Page as your top level page (parent) and then declare other pages as the Services pages’ children. You can do this on the page editing area in the WP admin area. Try not to mess with the permalinks as that … Read more

Second get_permalink inside loop points to wrong URL

get_permalink doesn’t output anything, it returns the permalink. Your first call works because you use it within the_title, which echos its value along with any before and after parameters you pass to it. Change your second instance to: <?php echo get_permalink(); ?> or use the_permalink, which echos the value instead of returning. <?php the_permalink(); ?> … Read more