Custom Metaviewport Tag
add_filter( 'wpex_meta_viewport', function() {
return '';
} );
Altering Layouts (Full Screen, No Sidebar, Left Sidebar, Right Sidebar)
/**
* Alter your post layouts
*
* @return full-width, full-screen, left-sidebar or right-sidebar
*
*/
add_filter( 'wpex_post_layout_class', function( $class ) {
// Alter your custom post type layout
if ( is_singular( 'YOUR_CPT' ) ) {
$class = 'full-width';
}
// Return correct class
return $class;
}, 20 );
Remove Recommended Plugins Notice
// Remove certain plugins
function my_recommended_plugins( $plugins ) {
// Remove notice to install WooCommerce
unset( $plugins['woocommerce'] );
// Return plugins
return $plugins;
}
add_filter( 'wpex_recommended_plugins', 'my_recommended_plugins' );
// Remove all plugins
// THIS IS NOT RECOMMENDED IF YOU ARE USING SOME OF THE PLUGINS SINCE THE NOTICE IS IS ALSO USED TO LET YOU KNOW OF UPDATES
add_filter( 'wpex_recommended_plugins', '__return_empty_array' );
Add/Remove Image Sizes
// Add & remove image sizes from the "Image Sizes" panel
add_filter( 'wpex_image_sizes', function( $sizes ) {
// Remove "blog_post_full" image size
unset( $sizes['blog_post_full'] );
// Add new image size "my_image_sizes"
$sizes['my_image_size'] = array(
'label' => __( 'My Image Size', 'wpex' ), // Label
'width' => 'my_image_size_width', // id for theme_mod width
'height' => 'my_image_size_height', // id for theme_mod height
'crop' => 'my_image_size_crop', // id for theme_mod crop
);
// Return sizes
return $sizes;
}, 9999 );
Allow Skype Links In The Theme
add_filter( 'kses_allowed_protocols', function( $protocols ){
$protocols[] = 'skype';
return $protocols;
} );
Alter The Default Excerpt Arguments
/* The Default arguments look like this:
$defaults = array(
'output' => '',
'length' => '30',
'readmore' => false,
'readmore_link' => '',
'more' => '…',
);
*/
// You can use a filter to alter these. It will also override any values inputed for the wpex_get_excerpt() function
function my_wpex_excerpt_args( $args ) {
// Set more tag to nothing
$args['more'] == '';
// Change more tag into a more link for portfolio posts
if ( 'portfolio' == get_post_type() ) {
$args['more'] = '…<a href="'. get_permalink() .'" title="'. wpex_get_esc_title() .'">'. __( 'Read More', 'wpex' ) .' →</a>';
}
// Return args
return $args;
}
add_filter( 'wpex_excerpt_args', 'my_wpex_excerpt_args' );
Remove Recommended Plugins
// Remove recommended plugins add_filter( 'wpex_recommended_plugins', '__return_empty_array' );
Remove/Hide The Edit Page/Post Links
body .post-edit { display: none !important; }
Conditionally Show/Hide The Footer Callout
function my_callout_visibility( $bool ) {
// Hide on the front page
if ( is_front_page() ) {
$bool = false;
}
// Return boolean
return $bool;
}
add_filter( 'wpex_callout_enabled', 'my_callout_visibility', 20 );
Alter Any Post Type Archive To Display Like the Blog
add_filter( 'wpex_is_blog_query', function( $bool ) {
if ( is_post_type_archive( 'events' ) ) {
$bool = true; // Make events post type archive render like blog posts
}
return $bool;
} );
Conditionally Disable/Enable The “Togglebar”
add_action( 'wpex_toggle_bar_active', function( $bool ) {
// Disable on blog archives (category/tag/date/author/blog template/format archives)
if ( wpex_is_blog_query() ) {
$bool = false;
}
// Return display
return $bool;
} );
Move Top Bar Outside The Header
/* The top bar is by default hooked into the header so when the header is disabled
* so is the top bar. However, you can move the Top Bar into a different hook to prevent that
*
* @deprecated Please update your theme because this is now the default structure in the latest version
* no need to add any code to your site.
*/
function my_move_top_bar() {
// Remove from the header hook
remove_action( 'wpex_hook_header_before', 'wpex_top_bar' );
// Re-add with low priority to make sure it comes before the header
add_action( 'wpex_hook_wrap_top', 'wpex_top_bar', 5 );
}
add_action( 'init', 'my_move_top_bar', 20 );
Conditionally Enable/Disable The “Topbar”
add_action( 'wpex_is_top_bar_enabled', function( $bool ) {
// Disable on checkout
if ( function_exists( 'is_checkout' ) && is_checkout() ) {
$bool = false;
}
// Return display
return $bool;
} );
Move Topbar Under Main Header
function myprefix_move_topbar() {
// Remove from wrap top
remove_action( 'wpex_hook_wrap_top', 'wpex_top_bar', 5 );
// Re-add to header after hook
add_action( 'wpex_hook_header_after', 'wpex_top_bar' );
}
add_action( 'init', 'myprefix_move_topbar' );
Topbar Custom Image Icons
function my_alter_top_bar_social_img_url() {
return get_stylesheet_directory_uri() .'/images/social/'; // Adjust accordingly.
}
add_filter( 'top_bar_social_img_url', 'my_alter_top_bar_social_img_url' );
Move Topbar Inside Header Wrapper (useful to add it inside the header Overlay)
function myprefix_move_topbar_to_header() {
remove_action( 'wpex_hook_wrap_top', 'wpex_top_bar', 5 );
add_action( 'wpex_hook_header_top', 'wpex_top_bar', 1 );
}
add_action( 'init', 'myprefix_move_topbar_to_header' );
Custom Topbar Social Link for Another Language (WPML)
add_action( 'after_setup_theme', function() {
// Get global Customizer settings
global $wpex_theme_mods;
// Check if topbar facebook value is set
if ( isset( $wpex_theme_mods['top_bar_social_profiles']['facebook'] ) ) {
// Get current language
$current_language = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : '';
// Update global variable to alter the value of the topbar social facebook link for this language
if ( 'he' == $current_language ) {
$wpex_theme_mods['top_bar_social_profiles']['facebook'] = 'HEBREW FACEBOOK PAGE';
}
}
}, 40 );
Add New Top Bar Social Options
add_filter( 'wpex_topbar_social_options', function( $options ) {
// Add phone number option
$options['phone'] = array(
'label' => 'Phone',
'icon_class' => 'ticon ticon-phone', // See http://fontawesome.io/icons/
);
// Return options
return $options;
} );
Conditionally Alter Topbar Content
add_filter( 'wpex_top_bar_content', function( $content ) {
if ( is_page( 'about' ) ) {
$content = 'Custom Content'; // Return custom content for the about page
}
return $content;
} );
Add Rel Nofollow To Top Bar Social Links
add_filter( 'wpex_topbar_social_link_attrs', function( $attrs ) {
$attrs['rel'] = 'nofollow';
return $attrs;
} );
Remove Top Bar Social Links Title Attributes
add_filter( 'wpex_topbar_social_link_attrs', function( $attrs ) {
unset( $attrs['title'] );
return $attrs;
} );
Move Aside Content On Top Of Logo For Header Three
// Move header aside content above logo by tweaking the action hooks
function move_header_aside() {
// Remove action
remove_action( 'wpex_hook_header_inner', 'wpex_header_aside' );
// Re-add with higher priority
add_action( 'wpex_hook_header_inner', 'wpex_header_aside', 0 );
}
add_action( 'init', 'move_header_aside' );
Add Secondary Custom Menu Under Header
function add_custom_menu_above_main_content() { ?>
<div class="my-nav-wrapper clr">
<div class="container clr"> <!-- .center the navbar content -->
<?php
// Solution 1 add the navbar shortcode
echo do_shortcode( '[vcex_navbar menu="60"]' ); // change the menu ID
// Solution 2 using WP menu see
// @ https://codex.wordpress.org/Function_Reference/wp_nav_menu for args
$args = array();
wp_nav_menu( $args );
// Solution 3 use a menu plugin such as uberMenu
do_shortcode( '[menu_shortcode_here]' ); ?>
</div>
</div>
<?php }
add_action( 'wpex_hook_header_after', 'add_custom_menu_above_main_content' );
Hide Footer Callout For All Blog Archives & Posts
function my_hide_callout_on_blog_archives( $bool ) {
if ( wpex_is_blog_query() || is_singular( 'post' ) ) {
$bool = false;
}
return $bool;
}
add_filter( 'wpex_callout_enabled', 'my_hide_callout_on_blog_archives', 20 );
Change Post Series Archive Layout
// Change Post Series Archive Layout
function my_alter_post_series_layout( $layout ) {
if ( is_tax( 'post_series' ) ) {
return 'full-width';
}
return $layout;
}
add_filter( 'wpex_post_layout_class', 'my_alter_post_series_layout' );
Change Post Series Archive Entry Style
/**
* Change Post Series Archive Entry Style
* Available options: large-image-entry-style, thumbnail-entry-style, grid-entry-style
*/
function my_post_series_entry_style( $style ) {
if ( is_tax( 'post_series' ) ) return 'grid-entry-style';
return $style;
}
add_filter( 'wpex_blog_style', 'my_post_series_entry_style' );
add_filter( 'wpex_blog_entry_style', 'my_post_series_entry_style' );
Change Post Series Order
// Change post series order from ASC to DESC
function myprefix_post_series_query_args( $args ) {
$args['order'] = 'DESC';
return $args;
}
add_filter( 'wpex_post_series_query_args', 'myprefix_post_series_query_args' );
Enable Post Series For Custom Post Type
/**
* Register series for post types
* This function register the taxonomy so you can now start using it, however it won't
* display the actual post series on the front-end, for that you need to use some extra code,
* we recommend adding a new blog for your post type via the theme filters (see useful links below)
* and in your custom blog you can use the code get_template_part( 'partials/blog/blog-single-series' )
* or you can copy and paste the code from the file at Total/partials/blog/blog-single-series into your new
* block for your post type so you can also modify it accordingly.
*
* @link http://wpexplorer-themes.com/total/snippets/add-new-portfolio-single-blocks/
* @link http://wpexplorer-themes.com/total/snippets/cpt-single-blocks/
* @link https://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type
*
*/
function myprefix_register_tax_for_objects() {
register_taxonomy_for_object_type( 'post_series', 'portfolio' );
}
add_action( 'init', 'myprefix_register_tax_for_objects' );
Automatically Display Featured Image At The Top Of Pages
function my_page_featured_image() {
if ( is_page() && has_post_thumbnail() ) {
echo '<div class="my-page-featured-image clr">'. get_the_post_thumbnail() .'</div>';
}
}
add_action( 'wpex_hook_main_top', 'my_page_featured_image', 10 );
Disable Page Header Title on ALL Pages
function my_disable_page_header( $bool ) {
if ( is_page() ) {
$bool = false; // this will allow meta options to work still
}
return $bool;
}
add_filter( 'wpex_display_page_header', 'my_disable_page_header' );
Hide Related Portfolio Heading
body .related-portfolio-posts-heading { display: none; }
Hide Related Portfolio Item Excerpt (CSS)
.related-portfolio-posts .portfolio-entry-excerpt { display: none; }
Disable Related Portfolio Item Excerpt (PHP)
function my_related_portfolio_excerpt_length( $length ) {
if ( is_singular() ) {
$length = '0';
}
return $length;
}
add_filter( 'wpex_portfolio_entry_excerpt_length', 'my_related_portfolio_excerpt_length' );
Tweak The Visual Composer Total Grid Filter Links Arguments
/**
* Tweak the VC portfolio grid filter arguments
*
* @link https://codex.wordpress.org/Function_Reference/get_terms
*/
function my_portfolio_grid_filter_args( $args ) {
$args['order'] = 'DESC';
return $args;
}
add_filter( 'vcex_portfolio_grid_filter_args', 'my_portfolio_grid_filter_args' );
Add Portfolio Category To Single Portfolio Post Slug
/**
* Add portfolio category to slug by altering register_post_type args.
* You can also do this in the editor dashboard instead
*
*/
function my_add_portfolio_category_term_to_slug( $args ) {
// Alter slug
$args['rewrite']['slug'] = 'portfolio-item/%portfolio_category%';
// Remove with front
$args['rewrite']['with_front'] = false;
// Return args
return $args;
}
add_filter( 'wpex_portfolio_args', 'my_add_portfolio_category_term_to_slug' );
/**
* Alter portfolio post type link
* This method can be used for any post type (staff/testimonials/portfolio) if tweaked correctly.
*/
function my_alter_portfolio_link( $url, $post ) {
// Return $url if %portfolio_category%/ not in slug or is not portfolio post type
if ( 'portfolio' != get_post_type( $post ) || strpos( $url, '%portfolio_category%' ) === false ) {
return $url;
}
// Get post terms
$terms = wp_get_object_terms( $post->ID, 'portfolio_category' );
// Get first term to use in front of slug
if ( ! is_wp_error( $terms ) && ! empty( $terms ) && is_object( $terms[0] ) ) {
$taxonomy_slug = $terms[0]->slug;
}
// Tweak url to turn %portfolio_category% into the first term slug
if ( ! empty( $taxonomy_slug ) ) {
$url = str_replace( '%portfolio_category%', $taxonomy_slug, $url );
}
// No terms found so simply remove %portfolio_category%
else {
$url = str_replace( '%portfolio_category%', '', $url );
}
// Return $url
return $url;
}
add_filter( 'post_type_link', 'my_alter_portfolio_link', 10, 2 );
Add Meta Option To Portfolio Posts For Disabling Auto Media
// Add option to Portfolio items to disable media
function my_new_portfolio_meta_options( $options ) {
// Add new setting to portfolio tab
$options['portfolio']['settings']['wpex_post_media'] = array(
'title' => __( 'Post Media', 'wpex' ),
'description' => __( 'Display media on single post?', 'wpex' ),
'id' => 'wpex_post_media',
'type' => 'select',
'options' => array(
'' => __( 'Yes', 'wpex' ),
'no' => __( 'No', 'wpex' ),
),
);
// Return all options
return $options;
}
add_filter( 'wpex_metabox_array', 'my_new_portfolio_meta_options', 40 );
// Disable portfolio post media by tweaking single blocks if disabled via custom-field
function my_portfolio_media_visibility( $blocks ) {
// Set block vals equal to keys for ease
$blocks = array_combine( $blocks, $blocks );
// If wpex_post_media field is set to 'no' then remove the media
if ( 'no' == get_post_meta( get_the_ID(), 'wpex_post_media', true ) ) {
unset( $blocks['media'] );
}
// Return layout blocks
return $blocks;
}
add_filter( 'wpex_portfolio_single_blocks', 'my_portfolio_media_visibility', 20 );
Add New “Blocks” To The Portfolio Post Layout
/**
* Example function for adding new "blocks" to the portfolio post layout manager.
*
* IMPORTANT: The module will be disabled by default, be sure to go to the Customizer
* to enable it.
*
*/
add_filter( 'wpex_portfolio_single_blocks', function( $blocks, $instance ) {
// Used for customizer setting to drag/drop the new module
if ( 'customizer' == $instance ) {
$blocks['tags'] = __( 'Tags', 'wpex' );
}
// Used for the front-end output
// Here you can define an anonymous function for the output or set the value to a function name used for the output.
else {
$blocks = array_combine( $blocks, $blocks );
// Add custom output for the tags
if ( isset( $blocks['tags'] ) ) {
$blocks['tags'] = function() {
// Get tags
$taxonomy = 'portfolio_tag';
$show_links = true;
$echo = false;
$tags = wpex_list_post_terms( $taxonomy, $show_links, $echo );
// Output tags
if ( $tags ) {
echo '<div class="my-portfolio-tags clr">' . $tags . '</div>';
}
};
}
}
// Return blocks
return $blocks;
}, 10, 2 );
Alter The Portfolio Related Posts Heading
// Alter The Portfolio Related Posts Heading
function my_portfolio_related_heading_args( $args ) {
// Show different text for items in category "design"
if ( has_term( 'design', 'portfolio_category' ) ) {
$args['content'] = 'Custom heading';
}
// Return args
return $args;
}
add_filter( 'wpex_heading_portfolio_related', 'my_portfolio_related_heading_args' );
Change Related Portfolio Query Arguments
// Change Related Portfolio Query Arguments
add_filter( 'wpex_related_portfolio_args', function( $args ) {
// Remove tax_query parameter so it doesn't try and display items from the same category
$args['tax_query'] = NULL;
// Change orderby parameter from random to date
$args['orderby'] = 'date';
// Return args
return $args;
} );
Portfolio Category Description Above Loop
function my_portfolio_category_description_above_loop( $bool ) {
if ( is_tax( 'portfolio_category' ) ) {
return true;
}
return $bool;
}
add_filter( 'wpex_has_term_description_above_loop', 'my_portfolio_category_description_above_loop' );
Add new staff social profiles
// Add new staff social profiles
add_filter( 'wpex_staff_social_array', function( $profiles ) {
// Add instagram
$profiles['instagram'] = array (
'key' => 'instagram',
'meta' => 'wpex_staff_instagram',
'icon_class' => 'ticon ticon-instagram',
'label' => 'Instagram',
);
// Return profiles
return $profiles;
} );
Add New “Blocks” To The Staff Post Layout
/**
* Example function for adding new "blocks" to the staff post layout manager.
*
* After adding your new blocks simply create a new file with the name "staff-single-YOUR_KEY.php"
* and place this file at partials/staff/ in your child theme. Make sure to replace "YOUR_KEY" with
* the key given in the array. So as an example for the function below you will create a file
* called single-custom-fields.php for your custom code
*
* IMPORTANT: This module will be disabled by default, so you will have to go to the Customizer to enable it.
*
*/
function my_staff_post_blocks( $blocks ) {
// Add new block "categories"
$blocks['custom-fields'] = __( 'Custom Fields', 'wpex' );
// Return blocks
return $blocks;
}
add_filter( 'wpex_staff_single_blocks', 'my_staff_post_blocks' );
Staff Category Description Above Loop
function my_staff_tax_description_above_loop( $bool ) {
if ( is_tax( 'staff_category' ) ) {
return true;
}
return $bool;
}
add_filter( 'wpex_has_term_description_above_loop', 'my_staff_tax_description_above_loop' );
Enable HTML For Staff Position
function myprefix_allow_staff_position_html( $position ) {
if ( $position ) {
return html_entity_decode( $position );
}
}
add_filter( 'wpex_staff_entry_position', 'myprefix_allow_staff_position_html' );
Order Related Staff by Name
// Alter the related staff posts query
function myprefix_custom_related_staff_args( $args ) {
// Change order from random to name
$args['orderby'] = 'title';
// Return args
return $args;
}
add_filter( 'wpex_related_staff_args', 'myprefix_custom_related_staff_args' );
Adding a First & Last Name Field for Staff Members
add_filter( 'wpex_metabox_array', function( $array ) {
// Make sure staff tab exists in arrray
if ( isset( $array['staff'] ) ) {
// Add First name to staff
$array['staff']['settings']['first_name'] = array(
'title' => __( 'First Name', 'total' ),
'description' => __( 'Field description', 'total' ),
'id' => 'wpex_first_name', // Custom field ID used to retrive via get_post_meta
'type' => 'text',
);
// Add Last name to staff
$array['staff']['settings']['last_name'] = array(
'title' => __( 'Last Name', 'total' ),
'description' => __( 'Field description', 'total' ),
'id' => 'wpex_last_name', // Custom field ID used to retrive via get_post_meta
'type' => 'text',
);
}
// Return meta array
return $array;
}, 40 );
Remove Staff Social Options
add_filter( 'wpex_staff_social_array', function( $profiles ) {
unset( $profiles['dribbble'] ); // Remove Dribble
unset( $profiles['skype'] ); // Remove Skype
return $profiles;
} );
Add Xing to Staff Social Profiles
// Add new staff social profiles
add_filter( 'wpex_staff_social_array', function( $profiles ) {
$profiles['xing'] = array (
'key' => 'xing',
'meta' => 'wpex_staff_xing',
'icon_class' => 'ticon ticon-xing',
'label' => 'Xing',
);
return $profiles;
}, 40 );
Remove Staff Meta Settings & Image Gallery
// Remove staff settings metabox
add_filter( 'wpex_main_metaboxes_post_types', function( $types ) {
unset( $types['staff'] );
return $types;
}, 40 );
// Remove staff gallery
add_filter( 'wpex_gallery_metabox_post_types', function( $types ) {
$types = array_combine( $types, $types );
unset( $types['staff'] );
return $types;
}, 40 );
Display Testimonial Post Title On Single Testimonials Page Header
function my_testimonials_page_title( $title ) {
if ( is_singular( 'testimonials' ) ) {
$title = get_the_title();
}
return $title;
}
add_filter( 'wpex_title', 'my_testimonials_page_title', 40 );
Add A Single Testimonial Shortcode
// Add a single testimonial shortcode
// Usage: [single_testimonial id="128"]
function myprefix_single_testimonial_shortcode( $atts ) {
ob_start();
extract( shortcode_atts( array(
'id' => '',
), $atts, 'single_testimonial' ) );
if ( $id ) {
$wpex_query = new WP_Query( array(
'post_type' => 'testimonials',
'post__in' => array( $id ),
'no_found_rows' => true,
) );
if ( $wpex_query->have_posts() ) :
while ( $wpex_query->have_posts() ) : $wpex_query->the_post();
if ( $template = locate_template( 'partials/testimonials/testimonials-entry.php', false ) ) {
include( $template );
}
endwhile;
endif;
wp_reset_postdata();
}
return ob_get_clean();
}
add_shortcode( 'single_testimonial', 'myprefix_single_testimonial_shortcode' );
Display Read More link for Testimonials with Custom Excerpts
add_filter( 'wpex_excerpt_output', function( $excerpt ) {
global $post;
if ( $post && 'testimonials' == $post->post_type && $post->post_excerpt ) {
$readmore = '<a href="'. get_permalink( $post->ID ) .'" title="Read More" rel="bookmark">read more <span class="wpex-readmore-rarr">→</span></a>';
return $post->post_excerpt .' '. $readmore;
}
return $excerpt;
} );
Enable the “Media” Post Settings For Custom Post Types
// Enable the "Media" post settings tab for custom post types
function my_add_meta_media_to_my_custom_type( $array ) {
$array['media']['post_type'][] = 'my_custom_type';
return $array;
}
add_filter( 'wpex_metabox_array', 'my_add_meta_media_to_my_custom_type', 40 );
Alter Meta Sections (date, comments, author, etc) For Custom Post Types
// Alter the meta sections array via the "wpex_meta_sections" filter
// For the blog use the 'wpex_blog_entry_meta_sections' or 'wpex_blog_single_meta_sections' instead
add_filter( 'wpex_meta_blocks', function( $sections ) {
// Your meta sections array ( you can move them around or remove some )
// This is the default array you could also just use unset to remove any
$sections = array( 'date', 'author', 'categories', 'comments' );
// Example of a meta section with a custom output
$sections['my_custom_block'] = function() {
echo 'my custom content';
};
// Return sections
return $sections;
} );
Enable Social Sharing On Custom Post Types
// Enable Social Sharing On Custom Post Types
add_filter( 'wpex_has_social_share', function( $bool ) {
if ( is_singular( 'YOUR_POST_TYPE_NAME' ) ) {
$bool = true;
}
return $bool;
}, 40 );
Add Overlay To Custom Post Type Entry
/**
* Example function for altering your entry overlay style for custom post types
* outside the scope of the theme.
*
* Available options: see Total/framework/overlays.php wpex_overlay_styles_array()
*
* @since 3.2.0
* @return string
*/
function myprefix_edd_entry_overlay() {
return 'title-push-up'; // Alter overlay for Easy Digital Downloads entry
}
add_filter( 'wpex_download_entry_overlay_style', 'myprefix_edd_entry_overlay' );
Add/Remove “Blocks” (Sections) From Custom Post Type Posts
/**
* Any custom post type post layout can be altered via the wpex_{post_type}_single_blocks filter
* which returns an array of the "blocks" or parts for the layout
* that will be loaded from partials/cpt/cpt-single-{block}.php
*
* Default array: array( 'media', 'title', 'meta', 'content', 'page-links', 'share', 'comments' );
*
* You can use the filter to add, remove or re-order elements in the array as you wish.
* Below is an example showing how to add a new block for a custom post type and remove one.
*
* After adding your new blocks simply create a new file with the name "cpt-single-YOUR_KEY.php"
* and place this file at partials/cpt/ in your child theme.
*
* IMPORTANT: Make sure to change {post_type} with your post type name
* IMPORTANT: Make sure to replace "YOUR_KEY" with the key given in the array (advertisement is the key for the block added below)
*
*/
add_filter( 'wpex_{post_type}_single_blocks', function( $blocks ) {
// Option 1: Add new block "advertisement" and create your cpt-single-advertisement.php file to add to your child theme
$blocks['advertisement'] = __( 'My Advertisement', 'total' );
// Option 2: Total 4.0+ only
// Add new blocks with custom function output
// Below is an example with an anonymous function but you can use custom functions as well ;)
$blocks['custom_block'] = function() {
echo 'my custom block';
};
// Remove the featured image from this post type
unset( $blocks['media'] );
// Return blocks
return $blocks;
} );
Add/Remove “Blocks” (Sections) From Custom Post Type Entries
/**
* Any custom post type post entry can be altered via the wpex_{post_type}_entry_blocks filter
* which returns an array of the "blocks" or parts for the layout
* that will be loaded from partials/cpt/cpt-entry-{block}.php
*
* Default array: array( 'media', 'title', 'meta', 'content', 'readmore' );
*
* You can use the filter to add, remove or re-order elements in the array as you wish.
* Below is an example showing how to add a new block for a custom post type and remove one.
*
* After adding new blocks simply create a new file with the name "cpt-entry-YOUR_KEY.php"
* and place this file at partials/cpt/ in your child theme.
*
* IMPORTANT: Make sure to change {post_type} with your post type name
* IMPORTANT: Make sure to replace "YOUR_KEY" with the key given in the array (advertisement is the key for the block added below)
*
*/
function myprefix_cpt_entry_blocks( $blocks ) {
// Example 1 - Add new block "advertisement" ( requires template part for output )
$blocks['advertisement'] = __( 'My Advertisement', 'total' );
// Example 2 - Added in Total 4.0+
// Add new blocks with custom function output
// Below is an example with an anonymous function but you can use custom functions as well ;)
$blocks['custom_block'] = function() {
echo 'my custom block';
};
// Return blocks
return $blocks;
}
add_filter( 'wpex_{post_type}_entry_blocks', 'myprefix_cpt_entry_blocks' );
Custom Post Type Post Thumbnail Arguments (size, alt, schema, style, etc)
/**
* Alter custom post type thumbnail arguments
* @see framework/core-functions wpex_get_post_thumbnail() function for a list of all available arguments
*
* IMPORTANT: Don't forget to change where it says "YOUR_POST_TYPE_NAME" to your post type name
*/
function my_prefix_cpt_post_thumbnail_arguments( $args ) {
return array(
'size' => 'full',
'width' => '900',
'height' => '400',
'crop' => 'center-center',
'alt' => wpex_get_esc_title(),
'schema_markup' => true,
);
}
add_filter( 'wpex_YOUR_POST_TYPE_NAME_entry_thumbnail_args', 'my_prefix_cpt_post_thumbnail_arguments' );
Enable The Image Gallery For Custom Post Types
add_filter( 'wpex_gallery_metabox_post_types', function( $types ) {
$types[] = 'your_post_type';
return $types;
} );
Easy Custom Post Type Entry Override
function myprefix_custom_template_parts( $parts ) {
// Override the output for your 'books' post type
// Now you can simply create a book-entry.php file in your child theme
// and whatever you place there will display for the entry
if ( 'books' == get_post_type() ) {
$parts['cpt_entry'] = 'book-entry';
}
// Return parts
return $parts;
}
add_filter( 'wpex_template_parts', 'myprefix_custom_template_parts' );
Related Items for Custom Post Type
// There isn't any built-in function for related items but you can easily add your own section with some code like this
// IMPORTANT => change "book" to your post type name
// IMPORTANT => change myprefix to your custom prefix for styling purposes
// IMPORTANT => this will add related to the bottom of your post
// if you don't want it there you can change the order of your "blocks" array or you can instead
// hook the output into a different theme hook http://wpexplorer-themes.com/total/docs/action-hooks/
add_filter( 'wpex_book_single_blocks', function( $blocks ) {
$blocks['related'] = function() {
// Query posts
$related = new WP_Query( array(
'post_type' => 'book',
'posts_per_page' => 3,
'no_found_rows' => true,
'post__not_in' => array( get_the_ID() ),
) );
if ( $related->have_posts() ) : ?>
<div class="myprefix-related-posts wpex-row clr">
<?php
// Columns number
$columns = 3;
// Define counter variable
$count = 0;
// Your loop
while ( $related->have_posts() ) : $related->the_post();
// Add to counter
$count++; ?>
<div class="myprefix-related-entry col span_1_of_<?php echo $columns; ?> col-<?php echo $count; ?> clr">
<a href="<?php wpex_permalink(); ?>" title="<?php wpex_esc_title(); ?>">
<?php wpex_post_thumbnail( array(
'width' => 500,
'height' => 300,
) ); ?>
</a>
<h2><a href="<?php wpex_permalink(); ?>" title="<?php wpex_esc_title(); ?>"><?php the_title(); ?></a></h2>
<?php wpex_excerpt( array(
'length' => 20,
) ); ?>
</div>
<?php
// Reset counter
if ( $count == $columns ) {
$count = 0;
}
endwhile; ?>
</div>
<?php endif; wp_reset_postdata(); ?>
<?php };
return $blocks;
}, 40 );
How To Remove Script Version Numbers
function wpex_remove_script_version( $src ) {
if ( strpos( $src, 'ver=' ) ) {
$src = remove_query_arg( 'ver', $src );
}
return $src;
}
add_filter( 'script_loader_src', 'wpex_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', 'wpex_remove_script_version', 15, 1 );
Custom Google Font Lists
function myprefix_google_fonts( $array ) {
return array( 'Open Sans', 'Roboto', 'Source Sans Pro' );
}
add_filter( 'wpex_google_fonts_array', 'myprefix_google_fonts' );
Add Version Number to Child Theme to Prevent Browser Cache
add_action( 'wp_enqueue_scripts', function() {
if ( ! defined( 'WPEX_THEME_STYLE_HANDLE' ) ) {
return;
}
// First de-register the main child theme stylesheet
wp_deregister_style( WPEX_THEME_STYLE_HANDLE );
// Then add it again, using filemtime for the version number so everytime the child theme changes so will the version number
wp_register_style( WPEX_THEME_STYLE_HANDLE, get_stylesheet_uri(), array(), filemtime( get_stylesheet_directory() . '/style.css' ) );
// Finally enqueue it again
wp_enqueue_style( WPEX_THEME_STYLE_HANDLE );
} );
Place An Advertisement Under Your Header/Menu
/**
* Place An Advertisement Under Your Header
* Use conditionals to show/hide accordingly
*
* @link https://codex.wordpress.org/Conditional_Tags
*
*/
function add_banner_after_header() { ?>
<div class="my-header-ad clr">
<div class="container clr"> <!-- .center the content -->
YOUR ADVERTISEMENT CODE HERE
</div><!-- .container -->
</div><!-- .my-header-ad -->
<?php }
add_action( 'wpex_hook_header_after', 'add_banner_after_header' );
Alter Editor Shortcodes Insert Button Default Value
add_filter( 'wpex_shortcodes_tinymce_json', function( $data ) {
// Alter the default insert code for the button shortcode
$data['shortcodes']['vcex_button']['insert'] = '[vcex_button url="http://www.google.com/" title="Visit Site" style="graphical" align="left" color="black" size="small" target="self" rel="none"]Button Text[/vcex_button]';
// Return data
return $data;
}, 40 );
Get & Display Term Thumbnail
if ( $thumb_id = wpex_get_term_thumbnail_id() ) {
$image = wpex_get_post_thumbnail( array(
'attachment' => $thumb_id,
'width' => '', // Int: Custom image width
'height' => '', // Int: Custom image height
'crop' => 'center-center', // Str: Crop location
'alt' => '', // Str: Custom alt tag for image
'class' => '', // Str: Add custom classes
'return' => 'html', // Str: Return html or src
) );
echo $image;
}
Disable WordPress SEO by Yoast Page Analysis
// Disable WordPress SEO by Yoast Page Analysis which seems to cause issues with the Visual Composer
function disable_wpseo_use_page_analysis() {
return false;
}
add_filter( 'wpseo_use_page_analysis', 'disable_wpseo_use_page_analysis' );
Re-Order Social Sharing Sites
// Re-Order Social Sharing Sites
function my_wpex_social_share_sites( $sites ) {
// Define the sites in your own order
$sites = array( 'twitter', 'facebook', 'google_plus', 'pinterest', 'linkedin' );
// Return sites
return $sites;
}
add_filter( 'wpex_social_share_sites', 'my_wpex_social_share_sites' );
Change The Theme Heading Border Color
body .theme-heading span.text:after {
border-color: #000;
}
Better RSS Feeds (Removes Shortcodes & Displays Thumbnail)
// IMPORTANT: Use this function to clear your RSS cache so you can see your changes, then REMOVE it
function prefix_set_feed_cache_time( $seconds ) {
return 0;
}
add_filter( 'wp_feed_cache_transient_lifetime' , 'prefix_set_feed_cache_time' );
// Custom RSS feed
function my_custom_rss_feed( $content ) {
// Get post
global $post;
// Generate 50 word excerpt using the Total wpex_excerpt function
// This will strip out shortcodes from the Visual Composer
$content = wpex_get_excerpt( array(
'length' => 50,
'more' => false // remove hellip
) );
// Display post thumbnail if defined
if ( has_post_thumbnail( $post->ID ) ){
$content = get_the_post_thumbnail( $post->ID, 'full', array( 'style' => 'float:left; margin:0 15px 15px 0;' ) ) . $content;
}
// Return the content
return $content;
}
add_filter( 'the_excerpt_rss', 'my_custom_rss_feed', 999 );
add_filter( 'the_content_feed', 'my_custom_rss_feed', 999 );
Add “nocookie” To WordPress oEmbeded Youtube Videos
// Add "nocookie" To WordPress oEmbeded Youtube Videos
function wpex_youtube_nocookie_oembed( $return ) {
$return = str_replace( 'youtube', 'youtube-nocookie', $return );
return $return;
}
add_filter( 'oembed_dataparse', 'wpex_youtube_nocookie_oembed' );
Alter The Image Width In The 1 Column Left Image & Right Content Grid
/* edit globally (can also be added in the VC custom CSS to target a specific page only) */
body .entries.left-thumbs .entry .entry-media { width: 20% }
body .entries.left-thumbs .entry .entry-details { width: 76% }
/* target specific grid */
.my-custom-class .entries.left-thumbs .entry .entry-media { width: 20% }
.my-custom-class .entry .entry-details { width: 76% }
Remove Text On Post Social Share Icons
body .wpex-social-share .wpex-label { display: none; }
TagCloud With Different Font Sizes
add_filter( 'widget_tag_cloud_args', function( $args ) {
$args['largest'] = '0.923'; // add your custom largest size here
$args['smallest'] = '0.923'; // Add your custom smallest size here
$args['unit'] = 'em'; // You can choose between em or px values
return $args;
}, 40 );
Disable URL Hash Update For Local Scroll Links
/**
* Disable hash update when clicking local scroll links
*
* @link 1.6.0
*
*/
function myprefix_disable_local_scroll_hash_update( $array ) {
$array['localScrollUpdateHash'] = false;
return $array;
}
add_filter( 'wpex_localize_array', 'myprefix_disable_local_scroll_hash_update' );
Make Page Content Background Transparent for Boxed Layout
/* Option 1 => Using Opacity */
.boxed-main-layout #wrap {
opacity: 0.8;
}
/* Option 2 => Using RGBA Colors */
.boxed-main-layout #wrap {
background: rgba(255,255,255,0.5);
}
.wpex-sticky-header-holder {
background: none;
}
.page-header,
#footer-callout-wrap {
background: rgba(255,255,255,0.5);
}
.site-footer {
background: rgba(000,000,000,0.7);
}
#footer-bottom {
background: rgba(000,000,000,0.5);
}

Docly
Accordion Slider PRO
Accordion Footer Menu Widget For Elementor