1

I've tried a few solutions I found online on this site and many others, but most issues are with theme users and not theme developers. There is a issue with my theme that I am building it is not setting Featured Image/Thumbnail in any type of template meaning pages, post, etc... I also can't remove ones that I preset manually!

I also noticed if I click Set Featured Image before the WordPress post page before it has full time to load it loads like a low bandwith window showing the media library and that allows me to select/set the image! Image of low bandwith media library below: enter image description here

What I tried:

  • Removing Plugins
  • Changing themes (which did allow me to set image)
  • Looking in the themes PHP for errors and reviewed documents on WP official development guide

But one thing I did notice is that on the media library when I go in to set a featured image there is this blank attachment that shows nothing no information. It only shows when setting featured image, does not show in the Media Library page. (See Image below)

enter image description here

I've added code that may be relevant to the issue:

if ( $post_type !== 'post' ) {

            register_post_type( $post_type,
                array(
                    'labels'            => array(
                        'name'          => __( ucfirst( $post_type ) ),
                        'singular_name' => __( $post_type ),
                    ),
                    'supports'          => array( 'title', 'thumbnail', 'editor', 'excerpt', 'author', 'comments', 'revisions', 'custom-fields'),
                    'show_ui'           => true,
                    'show_in_menu'      => true,
                    'show_in_nav_menus' => true,
                    'show_in_admin_bar' => true,
                    'taxonomies'        => array( 'category' ),
                    'public'            => true,
                    'has_archive'       => true,
                    'rewrite'           => array(
                        'slug' => strtolower( $post_type ),
                    ),
                )
            );

The error in the console shows: load-scripts.php?c=1&load[]=utils,jquery-core,jquery-migrate,plupload,quicktags&ver=4.7.5:5 POST admin-ajax.php 403 (Forbidden)

15
  • wordpress.stackexchange.com/a/165777/17923
    – inarilo
    Commented Jun 4, 2017 at 3:55
  • @inarilo I do have register_post_type support for thumbnails so I don't think that is it.
    – RTarson
    Commented Jun 6, 2017 at 0:39
  • Any javascript errors in the console ?
    – birgire
    Commented Jun 6, 2017 at 1:14
  • @birgire Yes indeed. It's only showing up in chrome not IE or Edge. I have added the error to my post
    – RTarson
    Commented Jun 6, 2017 at 1:19
  • 2
    You are using WP latest version, right? Also, could you please install Debug Bar plugin and activate debug mode via wp-config.php and see if you can give us more clues? Thanks. And, please, confirm that you have the following line in your functions.php: add_theme_support( 'post-thumbnails' ); And remember that add_theme_support is supposed to be called within 'aftter_setup_theme' action hook. Commented Jun 6, 2017 at 13:50

2 Answers 2

2

You added your own answer in the comments section:

There is only one total php warning/error:

wp-admin/admin-header.php:9 
- Cannot modify header information 
- headers already sent by 
(output started at 
    /home/content/p3pnexwpnas13_data03/47/3056147/html/wp-includ‌​es/functions.php:413‌​8) 
include('wp-admin/edit-form-advanced.php'), 
require_once('wp-admin/admin-header.php'), 
header…

The other half of the errors (it's two different problems you are facing) can also be found in your comments 1)

I also get 6x of these that come up but not sure if has anything to do with the theme.

Notice: wp_enqueue_style was called incorrectly. 
Scripts and styles should not be registered or enqueued until the 
wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. 
Please see Debugging in WordPress for more information. 
(This message was added in version 3.3.0.) 
in /home/content/p3pnexwpnas13_data03/47/3056147/html/wp-includ‌​es/functions.php on line 4138

The first problem is an error, which was raised in your AJAX call. The reason you do not get to see the error directly is, that —and this is what defines AJAX, the A is for asyncronous— the error was not in your current request, but in a request spawned by your current request, which ran in its own process in the background. Meaning: You will have to inspect the AJAX callback, the functionality that was called, to find the actual error.

Chrome has a nice set of debugging options available:

  1. You can replay that request without loading the whole page again, without repeating the process (e.g. opening a modal) and without bringing the request to a specific state. If you have a callback failing and are in local dev mode, simply change your AJAX endpoint handler, the callback script, hit Replay XHR and you will execute the callback with the changed code. Logical? Yes! Overseen? Yes, often.
  2. You can open any script that runs in the background, during an AJAX request, in a separate tab. That often makes error messages visible as they printed to the screen. Same here: Easy solution, but overseen by most devs.

The second problem is a race condition, a timing issue. A good indicator for a race condition is using a slow connection, something that you can for e.g. set and test in the Chrome developer tools. When things go slow, it's easier to notice and watch when one script finishes its task earlier than another one that relies on the result. If the result is not available, it will fail. When WordPress tells you, that you enqueued a script too early, then for the reason that some script, shipped with core and noted as a dependency, is not yet ready. Another thing that is noted there is that you enqueued the script before the Dependency API is not yet ready to accept enqueuing a new script. This means that WP will not take and load and output your script, making WP fail at this point.

enter image description hereenter image description here

1) Please, do not hide important information in comments. Always add them as edits to your question.

-1

Add below function to function.php

if (function_exists('add_theme_support')) { add_theme_support('post-thumbnails'); }
set_post_thumbnail_size( 100, 100, true ); // Normal post thumbnails

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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