Skip to content
Skip to content

Code Snippets

Here you'll find certain snippets to do some general common stuffs in Themify themes. Note that some snippets might not work in all themes.

General procedure to use a snippet

1. Create a child theme and create a functions.php in your child theme folder

2. Edit it, and paste this inserting the snippet you've chosen


<?php

// Snippet code goes here

?>

If you already have a child theme and the functions.php file, you only need to add the PHP code inside the <?php and ?> tags.

Add audio player to home page header


<?php

/**
 * Place an audio player in the header of the front page
 */
function custom_themify_home_audio_player() {
	if( is_front_page() )
		echo do_shortcode( '[audio mp3="http://www.roxyg/wp-content/uploads/YOUR-AUDIO-FILE.mp3" autoplay="true"]' );
}
add_action('themify_header_before', 'custom_themify_home_audio_player');

?>

Display the default Featured Image meta box again


<?php

/**
 * Display WordPress default Featured Image meta box
 */
remove_action('do_meta_boxes', 'themify_cpt_image_box');

?>

Add author capabilities to the "tile" custom post type

This code is generic: if you want to add author capabitilities to portfolio or team, just replace "tile" with the desired custom post type key.


<?php

/**
 * Add author capabilities to Tile post type
 */
function custom_themify_cpt_add_author() {
	add_post_type_support( 'tile', 'author' );
}
add_action('init', 'custom_themify_cpt_add_author');

?>