wp_enqueue_scripts not called on search page?
When using wp_enqueue_script, you probably passing true for in_footer parameter. If so, then check that your search.php is calling get_footer() function at the bottom.
When using wp_enqueue_script, you probably passing true for in_footer parameter. If so, then check that your search.php is calling get_footer() function at the bottom.
The reason you don’t see it if you dump object is because it’s not actual object property. WP_Post implements magical __get() method for ancestors and several more keys like that. When you access $post->ancestors() what you actually get is not some value from the object, but return of get_post_ancestors() function executed on it. So in … Read more
The first link on Google is to https://developer.wordpress.org/reference/functions/wp_mail/ which says that wp_mail is in wp-includes/pluggable.php It also has the full function source code showing that the first active line of the function is: $atts = apply_filters( ‘wp_mail’, compact( ‘to’, ‘subject’, ‘message’, ‘headers’, ‘attachments’ ) ); … which suggests that if you hook into the filter … Read more
Create a cron job for a function which checks the file size and runs unlink( WP_CONTENT_DIR . ‘/debug.log’ ) if necessary.
You can use the update_post_meta function to insert the Yoast Plugin data. Yoast uses 3 post meta keys for each post: _yoast_wpseo_title ( use for SEO title ) _yoast_wpseo_focuskw (For meta keywords ) _yoast_wpseo_metadesc (For meta descriptio ) You can find all these meta key under postmeta table $new_id = wp_update_post($array); update_post_meta( $new_id, ‘_yoast_wpseo_title’, ‘SEO … Read more
Try this code: function add_featured_image_body_class( $classes ) { global $post; if ( isset ( $post->ID ) && get_the_post_thumbnail($post->ID)) { $classes[] = ‘has-featured-image’; } return $classes; } add_filter( ‘body_class’, ‘add_featured_image_body_class’ );
I had a similar problem: calling error_log() from wp-config.php works, but calling it from functions.php does not work for me. I couldn’t solve this issue but I’ve found a workaround that allowed me to do some sort of debugging at least. I gave up on error_log() and just wrote an own function that logs into … Read more
One way to do that is to enable WP_DEBUG_LOG in wp-config.php. The file will look like this: define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_DISPLAY’, false ); define( ‘WP_DEBUG_LOG’, true ); //You may also set the log file path instead of just true Defining WP_DEBUG_LOG as true will save logs under wp-content/debug.log and you’ll find the PHP … Read more
echo $post->post_content; will echo your post content. Keep in mind though, it’s raw out of the database (same as get_the_content()). If you want to apply the same filters that the_content() receives, follow the instructions in the codex: <?php $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); ?>
WP-CLI is not different from any other server side utilities in that you need to be able to have the permission to run them out of a webserver enviroment using exec, spawn or friends. For obvious reasons all those kinds of PHP APIs are going to be blocked on most servers and therefor it is … Read more