How to download an MP3 file for offline use in iOS or Android

I took a look at a WordPress plugin, Easy Media Download, and it has a feature that adds a parameter to the <a> tag that forces a download. However, that only works for desktops browsers. If you are wanting to download the file in iOS or Android, you’re going to run into problems. That’s because they don’t have a file system like a computer that let’s you put files anywhere you like.

There are ways around this though. The mobile device wants to secure the phone by keeping files only associated with the apps that use them. So you could build your own app to download an mp3 file and store that file to be use only with that app. Not a quick or cheap solution. Another alternative is using Dropbox to store your mp3 files and share them. When you share the file Dropbox gives you an URL. Use this URL in your easy_media_download shortcode. What this will do (as long as the user has the Dropbox app installed on their phone) is download the file into their Dropbox account. From there they have the option to download the file for offline use.

Sample URL for a mp3 file in Dropbox used in the easy media shortcode:

[easy_media_download url=”https://www.dropbox.com/s/{{SOME_RANDOM_GENERATED_FILE_NAME.mp3?dl=1″ text=”Download TEST” color=”red” force_dl=”1″]

Using Easy Media Download shortcode to force a download at least for the desktop. Notice the extra force_dl=”1″ at the end. Probably not quite the answer you were looking for, but at least you know.

No Posts Found When Viewing Custom Taxonomy Archive Page

The problem: you know you have posts associated with a custom taxonomy, but they aren’t showing up. So you do a var_dump on the wp_query. You notice that the SQL query includes an odd statment: wp_posts.ID IN (0). That will always return¬†0 results. I thought I’ve seen this error before, but not remembering for sure, I disabled all the plugin. It worked. ¬†Then narrowed it down to a single plugin. The culpurit: Fantastic Elasticsearch.

The solution: re-index elasticsearch

SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  
	INNER JOIN wp_term_relationships ON 
		(wp_posts.ID = wp_term_relationships.object_id) 
	WHERE 1=1
		AND wp_posts.ID IN (0) 
		AND ( wp_term_relationships.term_taxonomy_id IN (1140) ) 
		AND wp_posts.post_type = 'article' 
		AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') 

	GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10

 

enable-for-all-custom-post-types-archives

The option to enable for all custom post types archives might also help too.

Add target=”_blank” to Mashmenu

If your site uses the Mashmenu plug and you would like one of your menu item links to open in a new window, Mashmenu provides the mashmenu_meta filter to do this. Just do a string replace on the href parameter to add the target=”_blank” parameter to the A tag.

Place this code in your theme’s functions.php file.

function mashmenu_page_content( $content ) {

	/* add target blank*/
	$content = str_replace('http://www.google.com/"', 'http://www.google.com/" target="_blank"', $content);
	return $content;

} add_filter('mashmenu_meta', 'mashmenu_page_content');

Resetting your password for WordPress when you cannot receive email

Use this activation URL to reset your WordPress password. You will need access to your database to get the activation key. This is a workaround I had to use on a development site that wasn’t sending emails.

http://domain.com/wp-login.php?action=rp&key={activation_key}&login={user_name}

WordPress Shortcode snippet

function bartag_func( $atts, $content = '' ) {
	extract( shortcode_atts( array(
		'foo' => 'something',
		'bar' => 'something else',
	), $atts ) );

	return "foo = {$foo}";
}
add_shortcode( 'bartag', 'bartag_func' );