I want to post objects which are not an Image/Video/Media in Wordpress, and I want to keep their original file format without renaming them to TXT extension, so that WordPress will accept the file in the post is this possible ?
I’ve searched for an answer and all I found was one tutorial where the author posted a PDF file and it worked but what about foreign file formats? No add-on, nothing.
You can… Just use the add media option, and make sure the format says all formats. I just uploaded a Word doc, linked and viewed it on a test post. It kept the docx format and showed up in my media library too.
add_filter('###,### 'programA,programB');
function custom_upload_mimes ( $existing_mimes=array() ) {
// Add file extension 'extension' with mime type 'mime/type'
$existing_mimes['###'] = 'application/<program-name>';
$existing_mines['###'] = 'application/<program-name>';
// add as many as you like e.g.
$existing_mimes['doc'] = 'application/msword';
// remove items here if desired ...
// and return the new full result
return $existing_mimes;
}
I placed this PHP code within Functions.PHP and WordPress Admin Login doesn’t load. The hashes represent the program extension.
I know you tweaked the code. However the code you provided earlier is invalid. The code provided by Vic is the proper way of coding it, and should work. Where are you putting Vic’s code?
‘SWK’ => ‘image/program’,
(fictitious extension, as far as I know)
here:
if ( !$mimes ) {
// Accepted MIME types are set here as PCRE unless provided.
$mimes = apply_filters( ‘upload_mimes’, array(
‘jpg|jpeg|jpe’ => ‘image/jpeg’,
Didn’t work, Victors code probably does work but where does it get placed ?