How to update WP about renamed files

Here is the code that works. Files are moved to ‘username’ folder and names for all files (including width x height) are updated. // Get all uploaded file attachment IDs $media_ids = $_POST[‘item_meta’][205]; // file upload field ID // Loop through each attachment foreach ( (array) $media_ids as $id ) { if ( ! $id … Read more

How to get the Page Number of the Current Page in Single Post Pagination

For your single page, you could try using the global $page variable. Another alternative would be to try fetching the query page variable, with e.g.: $wpse_current_page = (int) get_query_var( ‘page’ ); if( $wpse_current_page > 0 ) { printf( __( ‘Page Number: %d’, ‘wpse-theme-slug’ ), (int) $wpse_current_page ); } on your single page.

multiple if statements [closed]

Each of your if statements have the same has_term(‘NBS_CONS’, ‘broad_type_nbs’ ) function. This could be put in a variable for reuse instead. & Your argument for each if statement is actually very consistent, so much so you could probably reduce it by just putting your varying data in an array, loop though, and use Variable … Read more

White Screen of Death – wp-admin

I’d comment on Fayaz’s answer, but I don’t have enough reputation to comment. So here’s my additional advice: Along with checking hidden white space characters in wp-config.php file and elsewhere, I’d recommend you to temporarily disable all plugins and switch to the default WordPress Theme (e.g. Twenty Seventeen Theme). Then check if you still have … Read more

Convert all images to PNG on file upload

(Updated answer) The sight() function not only uploads the image, but also creates an attachment (i.e. a post of the attachment type); hence, I updated the code — it’s now in a function named attachment_to_png, and that it uses the get_attached_file() to get the image file attached to that attachment, and the update_attached_file() to update … Read more

Use ajax from function.php

As Milo already said in comment, jQuery is in noConflict mode in WordPress. This way other JS libraries can also use $ character… One way to solve it is using jQuery everywhere in your JS files. Another is to create block and define $ variable in it: jQuery(function ($) { $.ajax(…); // here you can … Read more

Converting MYSQL to WordPress $WPDB

The root problem here is the assumption that WordPress deals in mysql functions and mysql objects, and that knowledge of these functions is helpful. The truth is, this is a complete API in of itself, and so the assumptions that knowledge of mysql_ functions provides are not useful or relevant beyond the syntax of SQL. … Read more