Don’t prepend WordPress base url to image paths

You cannot insert remote file in this manner. <?php wp_insert_attachment( $attachment, $filename, $parent_post_id ); ?> $filename (string) (optional) Location of the file on the server. Use absolute path and not the URI of the file. The file MUST be in the uploads https://codex.wordpress.org/Function_Reference/wp_insert_attachment You should first download it to temp dir. If you wish to … Read more

Why is pre_get_posts hook invoked multiple times?

The pre_get_posts action runs any time posts are queried. This obviously includes the main query for displaying your latest posts or the current page, but it also includes any other time posts are queried. So that would include any use of WP_Query() or get_posts() in a plugin or your templates, any Recent Posts or similar … Read more

Is it possible to disable a theme programmatically?

here is no specialized hook for this. However the hook switch_theme should work for you. /** * Switches current theme to new template and stylesheet names. * * @since unknown * @uses do_action() Calls ‘switch_theme’ action on updated theme display name. * * @param string $template Template name * @param string $stylesheet Stylesheet name. */ … Read more

Security question – Display a General Custom Login Error Message

Add the following to your functions.php file. function my_custom_error_messages() { global $errors; $err_codes = $errors->get_error_codes(); // Invalid username. if ( in_array( ‘invalid_username’, $err_codes ) ) { $error=”<strong>ERROR</strong>: Custom Message Here”; } // Incorrect password. if ( in_array( ‘incorrect_password’, $err_codes ) ) { $error=”<strong>ERROR</strong>: Another Custom Message Here”; } return $error; } add_filter( ‘login_errors’, ‘my_custom_error_messages’); You … Read more

Re-order search results with posts_orderby filter and post meta value

Probably it’s just a JOIN problem: the SELECT query has no postmeta fields to order by. Try to implement the second answer from this question. That is, paste this code in your file. function custom_posts_join($join){ global $wpdb; $join .= ” LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id “; return $join; } add_filter( ‘posts_join’ , ‘custom_posts_join’);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)