Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / builder_blank_content_template.php
Created June 7, 2013 16:58
Builder blank page content template using the builder_layout_engine_render_content hook
<?php
/*Template Name: Blank */
function render_content() {
//CODE and INFORMATION GOES IN THIS FUNCTION
}
add_action( 'builder_layout_engine_render_content', 'render_content' );
@intelliweb
intelliweb / gf_inline_submit.css
Created April 15, 2013 05:02
WP: inline submit button using Gravity Forms. Handy when doing inline opt-in form.
.gform_footer.top_label {
float: right;
margin: -45px 0 0 0;
}
@intelliweb
intelliweb / style_input_placeholder.css
Last active December 16, 2015 05:39
CSS: style form input placeholder
input::-webkit-input-placeholder { /* Webkit - Yes, double :: is correct! */
color: #eaeaea;
}
input:-moz-placeholder { /* Firefox 4-18 */
color: #eaeaea;
}
input::-moz-placeholder{ /* Firefox 19+ */
color: #eaeaea;
}
input:-ms-input-placeholder { /* IE 10+ */
@intelliweb
intelliweb / add_shortcode.php
Last active January 3, 2018 15:10
WP: add shortcode. Replace SHORTCODE_TAG with whatever text you want to use in the shortcode.
<?php
// Shortcode: [SHORTCODE_TAG]
add_shortcode('SHORTCODE_TAG', 'intw_shortcode_SHORTCODE_TAG');
function intw_shortcode_SHORTCODE_TAG($atts) {
extract( shortcode_atts( array(
'att1' => 'DEFAULT_VALUE',
'att2' => 'DEFAULT_VALUE',
), $atts ) );
ob_start(); ?>
@intelliweb
intelliweb / domain_based_body_class.php
Created April 14, 2013 18:08
WP: dynamically add CSS class to body tag based on website domain. Useful when your using the same theme on all sites, but want to alter some styling (e.g. background) on some sites.
<?php
// Add custom CSS class to <body> tag
add_filter('body_class','intw_body_class');
function intw_body_class($classes) {
$url = get_bloginfo('url');
if( ($url == 'http://siteA.com') || ($url == 'http://devserver.com/siteA') ) {
$classes[] = 'siteA';
return $classes;
} elseif ( ($url == 'http://siteB.com') || ($url == 'http://devserver.com/siteB') ) {