1

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?

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

  • First things first -- you're sure the post/page you're trying to view actually exists? You can see it in the relevant Admin screens? – Pat J Jun 26 '13 at 16:15
  • How would I check? In production (pre-upgrade) all the product pages exist. The data in the databases should match since I dumped/restored from it – Edmund Jun 26 '13 at 16:16
  • 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. – Pat J Jun 26 '13 at 16:19
  • .... IT WORKED!! what the heck!!! How did that work?????? I don't remember ever going to that page – Edmund Jun 26 '13 at 16:28
  • Done. I also added a bit of explanation. (Other users: if I'm wrong in the details, by all means, correct me.) – Pat J Jun 26 '13 at 16:39
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.