How to find out which function is causing a 404

So I am trying to upgrade a WordPress project and for one section I get the 404 instead of seeing a product page. I looked around and tried adding this to my functions.php

    add_action('wp_head', 'show_template');
    function show_template() {
        global $template;
        print_r($template);
    }

but on the top it just shows me wordpress-3.5.2/wp-content/themes/mytheme/404.php. Can anyone teach me how to trace the error? WP_DEBUG_LOG does have a few depracations and stuff but I’m not sure if that’s relevant… Is there a systematic way to trace which function is responsible for this?

Read More

I’ll paste what WP_DEBUG shows just in case:

Notice: Undefined index: HTTPS in /Users/emai/Documents/wordpress_projects/mytheme/wordpress-3.5.2/wp-content/plugins/audio-player/audio-player.php on line 127

Notice: Undefined index: SERVER_PORT_SECURE in /Users/emai/Documents/wordpress_projects/mytheme/wordpress-3.5.2/wp-content/plugins/audio-player/audio-player.php on line 127

Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /Users/emai/Documents/wordpress_projects/mytheme/wordpress-3.5.2/wp-content/plugins/audio-player/audio-player.php:127) in /Users/emai/Documents/wordpress_projects/mytheme/wordpress-3.5.2/wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-constants.php on line 17

Notice: add_custom_background is deprecated since version 3.4! Use add_theme_support( ‘custom-background’, $args ) instead. in /Users/emai/Documents/wordpress_projects/mytheme/wordpress-3.5.2/wp-includes/functions.php on line 2841

Notice: add_custom_image_header is deprecated since version 3.4! Use add_theme_support( ‘custom-header’, $args ) instead. in /Users/emai/Documents/wordpress_projects/mytheme/wordpress-3.5.2/wp-includes/functions.php on line 2841

Notice: Undefined index: /js/js_gallery/jquery-1.6.1.min.js in /Users/emai/Documents/wordpress_projects/mytheme/wordpress-3.5.2/wp-includes/class.wp-scripts.php on line 163

Notice: Trying to get property of non-object in /Users/emai/Documents/wordpress_projects/mytheme/wordpress-3.5.2/wp-includes/class.wp-scripts.php on line 163
/Users/emai/Documents/wordpress_projects/mytheme/wordpress-3.5.2/wp-content/themes/mytheme/404.php

Related posts

1 comment

  1. Go to http://[your-site].com/wp-admin and have a look in the Posts or Pages menu (or if it’s a custom post type, the edit screens for your post type). Also, if it’s indeed there, check your permalinks (Settings > Permalinks) and save them even if you don’t make any changes. This will flush the permalinks, which might be all that’s needed.

    How it works: If you did a DB dump of your site, and then imported it into another DB, you’ll get all the posts/pages/sundry other content, but your Permalinks need to be flushed to make sure that WordPress understands that a request from the browser for, say, ‘/products/acme-widgets/foo’ is really a request for the post with $post->ID 39. If you make changes to the permalink structure, the permalinks need to be flushed. This doesn’t happen automatically because it’s an intensive process.

    Saving your Permalinks does a flush.

Comments are closed.