Undefined constant with debug set to true

I have used to following code to change the location of ‘single’ WordPress templates. define(SINGLE_PATH, TEMPLATEPATH.’/single/’); add_filter(‘single_template’, ‘lsmwp_custom_single’); function lsmwp_custom_single($single) { global $wp_query, $post; if ($post->post_type == “cpt_operator”){ if(file_exists(SINGLE_PATH . ‘/single-‘ . $post->post_type . ‘.php’)) return SINGLE_PATH . ‘/single-‘ . $post->post_type . ‘.php’; } foreach((array)get_the_category() as $cat) : if(file_exists(SINGLE_PATH . ‘/single-cat-‘ . $cat->slug . ‘.php’)) … Read more

add_sub_menu page() to be replaced by add_theme_page()

While checking my theme with theme-check plugin, i found few errors which are listed below along with the line of codes where it displays those errors(REQUIRED:) to be fixed. REQUIRED: plugin-activation.php. Themes should use add_theme_page() for adding admin pages. Line 335: add_submenu_page( add_submenu_page( $this->parent_menu_slug, // Parent menu slug $this->strings[‘page_title’], // Page title $this->strings[‘menu_title’], // Menu … Read more

Inserting Post Using wp_insert_post. How to Fill Yoast Plugin SEO Fields

I am inserting posts into a database using wp_insert_post function once the post is inserted using below line of PHP $postId = wp_insert_post($array) I can insert values in my advanced custom fields using add_post_meta function but I didn’t find anything to insert the SEO title or the meta description specifically in the Yoast SEO plugin. … Read more

What does this message from WP_DEBUG mean?

I have been having server 500 errors on 3 separate WordPress websites over the last while. (The problem BTW does seems to be related to the wordpress_logged_in***** cookie because deleting that always solves the problem temporarily) but this is not really my question … In the course of investigating this issue I turned on debugging … Read more

Where should I tell WordPress where error_log messages should be written?

I have two different instances of the same server (one for development, one for deployment), built independently but basically the same (same OS, same WordPress version, same content etc.). However, I’m confused about the configuration: it looks to me like they’re configured the same (except that the deployment server is told not to write errors/warnings … Read more

How to debug when error_log not working as expected

Trying to debug my development and running into a lot of frustrations with lack of output in the debug.log. For example, I have this defined in wp-config.php: define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true ); define( ‘WP_DEBUG_DISPLAY’, false ); ini_set( ‘display_errors’, 0 ); I have this in my functions.php add_filter( ‘the_content’, ‘my_custom_function’ ); function my_custom_function( … Read more

How to debug vars inside function at functions.php file?

I have this function: function wpse_210493_apply_advertising_position( &$posts, $return = false ) { $ad_posts = array(); $content_posts = array_filter( $posts, function ( $post ) { $position = get_post_meta( $post->ID, ‘rw_adversiting_position’, true ); if ( empty( $position ) ) { return true; } $ad_posts[ intval( $position ) ] = $post; return false; } ); $content_posts = array_values( … Read more