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
  • 00:59 (UTC +02:00)
View GitHub Profile
@eri-trabiccolo
eri-trabiccolo / custom_post_lists_comp.php
Last active August 29, 2015 14:16
Customizr > 3.3.11 <? custom post lists
<?php /*Add the following code at the very beginning of your template file, just after the Template declarative block */ ?>
<?php
// strangely you have to set this to false, typo in the core code.
// useful just when you display the page which uses this template in home as static page
// consider that the navigation will not work properly (and not because of customizr :P)
add_filter('tc_display_customizr_headings', '__return_false');
add_filter('tc_post_list_controller', '__return_true');
@eri-trabiccolo
eri-trabiccolo / menu_below_logo.php
Last active August 29, 2015 14:16
menu below the logo
/*Menu below the logo */
$navbar_wrapper_class = '';
add_action('wp', 'menu_below_logo');
function menu_below_logo(){
if ( ! method_exists('TC_menu', 'tc_menu_display') )
return;
global $navbar_wrapper_class;
$navbar_wrapper_class = implode( " ", apply_filters( 'tc_navbar_wrapper_class', array('navbar-wrapper', 'navbar-wrapper-below', 'clearfix', 'span12')));
@eri-trabiccolo
eri-trabiccolo / mobile_slider.php
Last active August 29, 2015 14:16
different slider on mobile + centering slider feature disabled
add_action('template_redirect', 'mobile_slider');
function mobile_slider(){
if ( ! ( tc__f('__is_home') && wp_is_mobile() ) )
return;
// remove the following filter if you wanna keep the slider centering feature
add_filter('tc_customizr_script_params', 'no_center_slides');
function no_center_slides($params){
$params['centerSliderImg'] = 0;
return $params;
}
@eri-trabiccolo
eri-trabiccolo / css_my_nav_menu_search.css
Created March 11, 2015 17:41
Search box in navbar CSS
/* my-nav-menu-search menu item created in functions.php. Move it way over to the right */
.navbar .nav .my-nav-menu-search {
float: right;
}
.navbar .nav {
width: 100%;
}
/*Stop the display of the Search button*/
.my-nav-menu-search .search-submit {
@eri-trabiccolo
eri-trabiccolo / sc_post_order_reverse.php
Created March 12, 2015 12:18
Reverse post order in a specific category
// Runs before the posts are fetched
add_action( 'pre_get_posts' , 'specific_category_reverse_post_order' );
function specific_category_reverse_post_order( $query ) {
// Alter only the primary query and only if we are in post lists context
// How to use is_category -> http://codex.wordpress.org/Function_Reference/is_category
if( ! ( $query->is_main_query() && is_category('3') ) )
return;
$query->set( 'order' , 'ASC' );
@eri-trabiccolo
eri-trabiccolo / home_2_posts_no_pag.php
Last active August 29, 2015 14:16
show two posts without pagination in home
add_action('pre_get_posts', 'show_two_posts_in_home');
function show_two_posts_in_home($query){
if ( ! is_admin() && $query -> is_main_query() && tc__f('__is_home') && ! tc__f('__is_home_empty') ){
$query->set('posts_per_page', 2);
// remove pagination
add_filter('tc_show_post_navigation', '__return_false', 999);
}
}
@eri-trabiccolo
eri-trabiccolo / two_selected_posts_in_blog_home.php
Last active August 29, 2015 14:17
show two selected posts in blog home
add_action('pre_get_posts', 'show_two_selected_posts_in_home_blog');
function show_two_selected_posts_in_home_blog($query){
if ( ! is_admin() && $query -> is_main_query() && is_home() && 'posts' == get_option('show_on_front') ){
$query->set('post__in', array(183, 94) ); //put your post IDs in that array
$query->set('ignore_sticky_posts', 1 ); //don't show sticky posts
}
}
@eri-trabiccolo
eri-trabiccolo / colophon_socials_title.php
Created March 15, 2015 15:09
add some text above colophon socials
add_filter('tc_colophon_left_block', 'add_html_above_socials');
function add_html_above_socials( $_html ){
$my_html = sprintf('<span class="my_social_title">%s</span>',
__('Follow us', 'customizr-child')
);
return str_replace( '<span', $my_html.'</span', $_html);
}
/* add this to your css, of course without comments :D
* and style it the way you want (display: block is the important part ;))
@eri-trabiccolo
eri-trabiccolo / pag_static_front_page.php
Created March 17, 2015 16:46
make pagination really work in static front pages
add_action('pre_get_posts', 'pagination_home');
function pagination_home( $query ){
if ( $query -> is_main_query() && is_page() && $query->get( 'page_id' ) == get_option( 'page_on_front' ) && $query->get('page') )
$query -> set('paged', $query->get('page') );
}
@eri-trabiccolo
eri-trabiccolo / something_below_sb_no_results.php
Created March 18, 2015 14:52
add something below the search box in no results pages
add_filter( 'tc_no_result_content', 'add_something_below_search_box' );
function add_something_below_search_box( $_html){
$html = 'something';
return str_replace('</form>', '</form>'.$html, $_html);
}