Importing Attachments with No Extension

With no native solution popping up here, I ended up writing a script that Parsed my the XML import file I had and identified problem attachments Manually download those attachments with a file extension Upload those images to a new web server Alter the appropriate link and wp:attachment_url nodes to point to the new URLs … Read more

How to remove attachments from main query via pre_get_posts?

Rather than using pre_get_posts hook, you could try a better approach which will work perfectly with parse_request hook. The code – add_action( ‘parse_request’, ‘my_cpt_parse_request’, 11, 2 ); function my_cpt_parse_request( $wp ) { if( isset($wp->request) && !is_admin() ) { $requests = explode(“https://wordpress.stackexchange.com/”, $wp->request); $request_amount = count($requests); $post_name = array_shift( $requests ); // if an attachment has … Read more

Add link to attachment for old posts

You can use the the_content filter to access the contents of the post before it is printed to the screen. The function that you use to filter it can either go two routes – using regex to parse the contents (not the “right” way but faster/dirtier) or an HTML parser. You should then be able … Read more

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