Skip to content

Instantly share code, notes, and snippets.

View theodorocaliari's full-sized avatar
💻

Theodoro Caliari theodorocaliari

💻
View GitHub Profile
@theodorocaliari
theodorocaliari / WP-enqueue-style-child-theme.php
Last active December 19, 2015 06:49
Call style recommended practice in functions.php of WordPress
<?php
function custom_style(){
$css = dirname(get_bloginfo('stylesheet_url'))."/your_style.css";
wp_register_style('name_ur_choice', $css);
wp_enqueue_style('name_ur_choice');
}
add_action('wp_enqueue_scripts', 'custom_style', $priority);
?>
@theodorocaliari
theodorocaliari / WP-prevent-direct-access.php
Created July 2, 2013 22:22
Prevent direct access to include file in WordPress
<?php
if ( ! defined( 'WPINC' )) {
die;
}
?>
@theodorocaliari
theodorocaliari / remove-adminbar-front-end-wp.php
Last active December 19, 2015 07:09
Remove Wordpress admin top bar in front-end for all users.
<?php
//http://www.paulund.co.uk/remove-the-wordpress-admin-bar
if (!current_user_can( 'manage_options' )){
add_filter( 'show_admin_bar', '__return_false' );
}
?>
@theodorocaliari
theodorocaliari / Preferense.sublime-settings.json
Last active December 19, 2015 07:48
My ST2 user settings
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_size": 14.0,
"word_wrap": true,
"save_on_focus_out": true,
"tab_size": 2,
"translate_tabs_to_spaces": false,
"enable_tab_scrolling": false,
}
@theodorocaliari
theodorocaliari / posts_page_conditional.php
Created July 13, 2013 23:21
Conditional for WordPress posts page
<?php
if( is_home('page_name_defined_in_settings_reading_wp_admin_menu') )
{
// code
}
?>
<?php
/*remove comments*/
//http://themeshaper.com/forums/topic/removing-comments-section-from-thematic
function remove_comments(){
if (is_page()){
remove_action('thematic_comments_template','thematic_include_comments',5);
}
}
add_action('template_redirect','remove_comments');
@theodorocaliari
theodorocaliari / add_excerpt_in_pages.php
Created August 8, 2013 10:51
Add excerpt in wordpress pages. Adicionar resumo nas paginas do wordpress.
<?php
add_action('init', 'my_custom_init');
function my_custom_init() {
add_post_type_support( 'page', 'excerpt' );
}
?>
@theodorocaliari
theodorocaliari / limit_char_number.php
Created August 8, 2013 10:54
Limit character number in wordpress. Limitar número de caracteres no wordpress. Reference: http://bavotasan.com/2009/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/
<?php
#limit chars
function excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
@theodorocaliari
theodorocaliari / get_the_slug.php
Created August 16, 2013 12:38
Get page/post slug in wordpress
<?php
/*paste this in functions.php*/
function the_slug() {
global $post;
$slug = $post->post_name;
return $slug;
}
/* --- */
/*call your slug in your page*/