Uncaught Error: Undefined constant “WP_CONTENT_DIR”

Yes, this is a bug, but it appear only when the WP configuration is not finished. The error occurs on this line (in wp-includes/load.php) : if ( ! extension_loaded( ‘mysql’ ) && ! extension_loaded( ‘mysqli’ ) && ! extension_loaded( ‘mysqlnd’ ) && ! file_exists( WP_CONTENT_DIR . ‘/db.php’ ) ) { (…) This checks that mysql … Read more

How can I access user information on a subdomain?

Found two solutions: 1) global $current_user; $wp_get_current_user_id = $current_user->ID; $wp_get_current_user_id = apply_filters( ‘determine_current_user’, false ); Which then in helloworld.php would be return: echo json_encode( array(‘wordpress_user_id’ => wp_get_current_user_id) );

Pagination URL not good

It looks like you’ve attempted to replace the default WP_Query object for your search page by instantiating a new WP_Query object. This has two main effects: firstly you’re hitting the database twice completely unnecessarily, slowing down the page execution; and secondly default template functionality like pagination depends on the default query for the page rather … Read more

Redirect to File attached to a Post using ACF

The action redirect_to_acf_file_url doesn’t exist, at least not in stock WordPress. You’ll need to supply a proper action hook, and it’ll need to be one that happens before any output is sent to the browser. I’d recommend something like init or wp. add_action() takes a hook name and a function name. <?php function redirect_to_acf_file_url() { … Read more

Adding a css class to the gallery

If you look at the gallery shortcode you will see that you are using the wrong filter. With post_gallery you can override the complete html of the shortcode. Your code performs a str_replace on an empty string, resulting in an empty return and subsequently the generation of the default gallery html. Further on there is … Read more

SQL command to delete bulk WP post specific

Deleting posts directly in the DB is not going to clear up all their comments, post metadata, etc. I’d recommend using wp_delete_post() to do this instead. // Gets the post IDs. $author_id = get_user_by( ‘login’, ‘newsagencies’ ); // Use the user’s login here. $posts = new WP_Query( array( ‘author’ => $author_id, ‘date_query’ => array( ‘after’ … Read more

Fatal error on random blog posts

Pretty simple. comments.php is trying to call a function twentyseventeen_get_svg() which doesn’t exist: Uncaught Error: Call to undefined function You’ll probably need to contact the theme developer or, just find the part of the code in comments.php (line 88) that calls the function and comment it out. Looks like that function comes with the theme … Read more