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
  • 07:30 (UTC +02:00)
View GitHub Profile
@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);
}
@eri-trabiccolo
eri-trabiccolo / display_the_same_slider_everywhere.php
Created March 18, 2015 17:45
Display the same slider everywhere
add_filter( 'tc_show_slider' , '__return_true' );
add_filter( 'tc_slider_active_status' , '__return_true' );
//display in full width ?
add_filter( 'tc_slider_layout' , '__return_true' );
//force the slider name to the front page slider name
add_filter( 'tc_slider_name_id', 'force_slider_name');
function force_slider_name() {
return method_exists('TC_utils', 'tc_opt') ? TC_utils::$inst->tc_opt( 'tc_front_slider' ) : '';
}
add_filter('tc_default_socials', 'reorder_socials', 11);
function reorder_socials( $_socials ){
/* available socials are (in the following order)
tc_rss
tc_twitter
tc_facebook
tc_google
tc_instagram
tc_tumblr
tc_flickr
@eri-trabiccolo
eri-trabiccolo / show_date_before_title_in_post_lists.php
Created March 21, 2015 17:57
Show the date before the title in post lists
/* will not work with the expanded post in post list grid */
add_action('__before_content_title', 'show_date_before_title');
function show_date_before_title(){
$method_exists = ( array_product( array(
method_exists('TC_post_metas', 'tc_get_meta_date'),
method_exists('TC_post_list', 'tc_post_list_controller'),
method_exists('TC_post_list_grid', 'tc_is_grid_enabled'),
)));
if ( $method_exists && ( TC_post_list_grid::$instance -> tc_is_grid_enabled() || TC_post_list::$instance -> tc_post_list_controller() ) )
@eri-trabiccolo
eri-trabiccolo / move_home_slider.php
Last active August 29, 2015 14:17
Move Customizr(-Pro) home slider inside the #content
$my_home_slider_height = '250'; /*in pixels*/
function is_home_slider(){
$tc_front_slider = TC_utils::$inst->tc_opt( 'tc_front_slider' );
return ( tc__f('__is_home') && $tc_front_slider && method_exists('TC_slider', 'tc_slider_display') );
}
add_action('template_redirect', 'my_home_slider_in_content', 100);
function my_home_slider_in_content(){
if ( ! is_home_slider() )
@eri-trabiccolo
eri-trabiccolo / show_date_before_title_in_posts_pages.php
Created March 22, 2015 09:51
Show the date before the title in post/page
add_action('__before_content_title', 'show_date_before_title');
function show_date_before_title(){
$show_in_pages = false;
if ( method_exists('TC_post_metas', 'tc_get_meta_date') && ! ( is_page() && ! $show_in_pages ) )
echo TC_post_metas::$instance->tc_get_meta_date();
}
@eri-trabiccolo
eri-trabiccolo / search_box_below_header.php
Created March 22, 2015 11:45
Search box below header
add_theme_support( 'html5', array( 'search-form' ) );
add_action('__after_header', 'my_woocommerce_search_form');
function my_woocommerce_search_form(){
$search_form = '<div class="row-fluid"><div class="my-search-box span12">' . get_search_form(false) . '</div></div>';
echo $search_form;
}
/* part to copy into the custom css or child-theme style.css DO NOT COPY INTO THE CHILD THEME functions.php !
.my-search-box{
padding: 20px 10px;
-webkit-box-sizing: border-box;