How to remove “YEAR/MONTH/” from uploads URL & redirect old URL to the new form?

The .htaccess RewriteRule to rewrite only .pdf to not use /year/month/ can look like this RewriteRule ^wp-content/uploads/([0-9]+)/([0-9]+)/(.+?)$ /wp-content/uploads/$3.pdf [L,R=301] You should add this prior to WordPress’ rules, so it will be evaluated before them, resulting in a .htaccess file like this <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^wp-content/uploads/([0-9]+)/([0-9]+)/(.+?)\.pdf$ /wp-content/uploads/$3.pdf [L,R=301] </IfModule> # BEGIN WordPress … Read more

Remove all table widths from editor content

I would approach this by modifying the attributes allowed in the table, tr, and td markup from wp_kses. wp_kses is a function that runs on the content to filter out unwanted tags and attributes. It stands for KSES Strips Evil Scripts, but it does much more than that. It’s a large and sometimes convoluted function, … Read more

Getting results from wp_oembed_add_provider

Ok I managed to solve this! Did some digging through how the embed system works, and it turns out it wasn’t the use of wp_oembed_add_provider() that was wrong. Debugging autoembed_callback() in wp-includes\class-wp-embed.php showed that my YouTube URL was coming through but my Facebook URL never made it to this function. Echo’ing the post content before … Read more

Adding Automatically To In WordPress Using Filter Referencing?

You can filter the_content and use preg_replace() to look for instances of <table></table> and then surround them with your <div>. add_action( ‘the_content’, ‘wpse_260756_the_content’, 10, 1 ); function wpse_260756_the_content( $content ) { $pattern = “/<table(.*?)>(.*?)<\/table>/i”; $replacement=”<div class=”table-responsive”><table$1>$2</table></div>”; return preg_replace( $pattern, $replacement, $content ); }

sql query to put quotes around numbers in img tag

You are simply going to love this one First of all, here is a sample table with data loaded: mysql> use junk Database changed mysql> drop table todd; Query OK, 0 rows affected (0.01 sec) mysql> create table todd (id int not null auto_increment,url VARCHAR(255), -> primary key (id)) ENGINE=MyISAM; Query OK, 0 rows affected … Read more