Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

Custom Post Type redirects to 404 page

This function from dev4press really helped me debug my custom post type redirect to a 404 page.

 

Place this code in your functions.php file:

function dev4press_debug_page_request() {
		global $wp, $template;

		echo '<pre>!-- Request: ';
		echo empty($wp->request) ? "None" : esc_html($wp->request);
		echo ' -->'.PHP_EOL;
		echo '!-- Matched Rewrite Rule: ';
		echo empty($wp->matched_rule) ? None : esc_html($wp->matched_rule);
		echo ' -->'.PHP_EOL;
		echo '!-- Matched Rewrite Query: ';
		echo empty($wp->matched_query) ? "None" : esc_html($wp->matched_query);
		echo ' -->'.PHP_EOL;
		echo '!-- Loaded Template: ';
		echo basename($template);
		echo ' --></pre>'.PHP_EOL;
	}

Place this in your template file:

dev4press_debug_page_request();

echo '<h1>Rewrite Rules</h1>';

global $wp_rewrite;

echo '<pre>';
print_r($wp_rewrite->rules);
echo '</pre>';

Leave a Reply