Skip to content

Instantly share code, notes, and snippets.

@intelliweb
intelliweb / builder_custom_css_file.php
Created June 14, 2013 17:50
Builder: Enqueue custom stylesheet (custom.css) in the child theme directory to keep custom CSS code separate from style.css -- custom.css overrides style.css
<?php
// Enqueue custom stylesheet in child theme directory
function intw_custom_styles() {
wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri() . '/custom.css', '1.0.0', 'all' );
}
add_action('wp_enqueue_scripts', 'intw_custom_styles');
@intelliweb
intelliweb / translate_text.php
Created August 3, 2013 16:20
Translate text in WordPress
<?php
function turn_post_into_article($translated){
$translated = str_ireplace('Post', 'Article', $translated);
return $translated;
}
add_filter('gettext', 'turn_post_into_article');
add_filter('ngettext', 'turn_post_into_article');
@intelliweb
intelliweb / social_sharing_links.php
Created August 3, 2013 16:24
Links for sharing posts on several social networks. Using these HTML links vs. buttons/badges provided by social networks is much better for performance (no javascript files, iframes, etc. to load)
@intelliweb
intelliweb / post_divider.php
Created August 3, 2013 16:26
Add divider between WordPress posts, skipping the last one. Source: http://css-tricks.com/snippets/wordpress/post-divider/
<?php
if (($wp_query->current_post + 1) < ($wp_query->post_count)) {
echo '<div class="post-item-divider">Post Divider</div>';
}
@intelliweb
intelliweb / delayed_fadein.html
Created August 7, 2013 15:15
Delayed fade-in effect on element
<script type="text/javascript">
jQuery(function() {
jQuery('#element-ID').hide().delay(5000).fadeIn(2200);
});
</script>
@intelliweb
intelliweb / jquery_waypoints.md
Created August 28, 2013 04:49
Use jQuery Waypoints Sticky Elements to create sticky navigation menu

STEP 1

Add the following to theme's functions.php file (modify module type if needed):

// Add Support for Alternate Module Styles
add_action( 'it_libraries_loaded', 'it_builder_loaded' );
if ( ! function_exists( 'it_builder_loaded' ) ) {
  function it_builder_loaded() {
		builder_register_module_style( 'navigation', 'Sticky Navigation', 'navigation-sticky' );
	}
@intelliweb
intelliweb / featured_image.php
Created September 4, 2013 18:52
WP: Featured image as banner with default image if no featured image is selected
#replace {
background: url("myimage") 0 0 no-repeat;
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
@intelliweb
intelliweb / featured_image_background.php
Created October 4, 2013 02:12
WP: Featured image as background
@intelliweb
intelliweb / builder_filter_current_layout.php
Created October 5, 2013 07:48
Builder: Filter to assign a layout using layout ID
<?php
add_filter('builder_filter_current_layout', 'intw_builder_filter_current_layout');
function intw_builder_filter_current_layout( $layout_id ) {
if ( is_single() && in_category( 'news' ) )
return '4e5f997043d8e';
return $layout_id;
}