Skip to content

Instantly share code, notes, and snippets.

View eri-trabiccolo's full-sized avatar
❤️
@thomasplevy is my buddy

Rocco Aliberti eri-trabiccolo

❤️
@thomasplevy is my buddy
  • Pinerolo (TO), Italy
  • 20:40 (UTC +02:00)
View GitHub Profile
@eri-trabiccolo
eri-trabiccolo / home_slider_before_menu.php
Created September 9, 2015 14:17
Move home slider before menu
//we hook the code on the wp_head hook, this way it will be executed before any html rendering.
add_action ( 'wp_head' , 'move_my_slider');
function move_my_slider() {
if ( ! tc__f('__is_home') ) return;
//we unhook the slider
remove_action( '__after_header' , array( TC_slider::$instance , 'tc_slider_display' ));
//we re-hook the slider. Check the priority here : set to 0 to be the first in the list of different actions hooked to this hook
add_action( '__navbar' , array( TC_slider::$instance , 'tc_slider_display' ), 20);
}
@eri-trabiccolo
eri-trabiccolo / sidenav_warea_no_mainmenu.php
Created September 9, 2015 08:55
Widget area in the side nav in place of the main menu
add_filter('wp_nav_menu_items', 'remove_main_menu', 10, 2);
function remove_main_menu($items, $args) {
// If this isn't the main navbar menu, do nothing
if( !($args->theme_location == 'main') ) // with Customizr Pro 1.2+ and Cusomizr 3.4+ you can chose to display the saerch box to the secondary menu, just replacing 'main' with 'secondary
return $items;
return '<li></li>'; /*Pretend an empty main menu*/
}
//Create widget area
add_filter( 'tc_default_widgets' , 'add_sn_widget_area' );
function add_sn_widget_area( $defaults ) {
@eri-trabiccolo
eri-trabiccolo / footer_credits_qtranslatex.php
Created September 8, 2015 08:56
Footer credits qtranslateX compatibility
@eri-trabiccolo
eri-trabiccolo / current_category_posts_no_children.php
Last active September 18, 2016 00:03
Show posts of the current category - no children
add_action('pre_get_posts', 'only_parent_category');
function only_parent_category( $query ){
if ( is_admin() || ! $query -> is_main_query() || ! is_category() )
return;
$query->set('category__and', get_queried_object_id());
//or with the same effect
//$query->set('category__in', get_queried_object_id());
//see https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
}
@eri-trabiccolo
eri-trabiccolo / search_form_before_menu.php
Created August 31, 2015 13:54
Search form before menu
add_action ( '__navbar' , 'add_search_form_before_menu' , 25 );
function add_search_form_before_menu(){
$search_form = '<div class="my-header-search span12">' . get_search_form(false) . '</div>';
echo $search_form;
}
add_shortcode('do_fp', 'do_fpu');
function do_fpu(){
add_filter('tc_show_fp', '__return_true');
ob_start();
do_action('custom_fpu_hook');
$html = ob_get_contents();
ob_end_clean();
return $html;
}
@eri-trabiccolo
eri-trabiccolo / smoothscroll_options.php
Created August 24, 2015 07:28
Smoothscroll options
add_filter('tc_smoothscroll_options', 'my_smoothscroll_options');
function my_smoothscroll_options( $params ){
/* Regulate the scroll step above, default is 150 */
$params['stepSize'] = 60;
/* Regulate the animation time with the param above, default is 400 */
// $params['animationTime'] = 600;
return $params;
}
@eri-trabiccolo
eri-trabiccolo / fw_home_wa_after_home_slider.php
Last active August 29, 2015 14:27
Full-width home widget area after the home slider
add_filter( 'tc_default_widgets' , 'add_fw_home_widget' );
function add_fw_home_widget( $defaults ) {
$defaults['fw_widgets_home'] = array(
'name' => __( 'Full width widget area' , 'customizr' ),
'description' => __( 'Above the featured pages area in home' , 'customizr' )
);
return $defaults;
}
add_action('__after_header', 'display_fw_widget_home', 12);
function display_fw_widget_home(){
@eri-trabiccolo
eri-trabiccolo / wrap_single_post_content.php
Created August 20, 2015 08:08
Wrap single post content in a custom container
//Wrap single post contents
add_action('__before_article', 'my_wrapper_start', 0);
function my_wrapper_start(){
if ( ! is_single() ) return;
echo '<div id="my_article_wrapper" class="article-wrapper">';
}
add_action('__after_article_container', 'my_wrapper_end', 0);
function my_wrapper_end(){
if ( ! is_single() ) return;
echo '</div>';
@eri-trabiccolo
eri-trabiccolo / warea_before_fp_mobile.php
Created August 19, 2015 15:51
(Pro) Display widget area in mobiles before the featured pages
// define our widget area
add_filter( 'tc_default_widgets' , 'add_featured_page_widget' );
function add_featured_page_widget( $defaults ) {
$defaults['mobile_widgets_home'] = array(
'name' => __( 'Mobile widget area' , 'customizr' ),
'description' => __( 'Above the featured pages area on home in mobiles only' , 'customizr' )
);
return $defaults;
}
// display it before the featured pages in home only for mobiles