Skip to content

Instantly share code, notes, and snippets.

View ScarletPonytail's full-sized avatar

ScarletPonytail ScarletPonytail

View GitHub Profile
@ScarletPonytail
ScarletPonytail / functions.php
Last active June 1, 2017 13:32
CSS - Spinny Social Icons
// Add Font Awesome for social icons
function font_awesome() {
echo '<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet" />';
}
add_action('wp_head', 'font_awesome');
@ScarletPonytail
ScarletPonytail / functions.php
Last active June 8, 2017 14:13
Wordpress - functions.php add style and scripts to header and footer
// Add style.css to header
// ----------------------------------
function vinx_style() {
wp_enqueue_style( 'Vin-X Style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'vinx_style' );
// Add Script to header
@ScarletPonytail
ScarletPonytail / _variables.scss
Last active June 8, 2017 14:13
Wordpress - Add Google Fonts to functions.php
$font-family-sans-serif: 'Roboto', sans-serif !default;
$font-family-serif: 'Lobster Two', cursive !default;
$font-family-special: 'Libre Franklin', sans-serif !default;
@ScarletPonytail
ScarletPonytail / footer.php
Last active June 8, 2017 14:13
Wordpress - Create Widget in functions.php and adding it to the theme
@ScarletPonytail
ScarletPonytail / page-home.php
Last active March 30, 2017 12:32
Wordpress - Add posts 'Loop' of a certain category to theme file
// This example will display 3 posts from category 7
<?php query_posts('showposts=3&cat=7'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="col-md-4">
<h3><?php the_title(); ?></h3>
<?php the_excerpt(__('(more…)')); ?>
<a class="btn btn-default" href="<?php the_permalink() ?>" role="button">Read More</a>
</div>
<?php endwhile; endif; ?>
@ScarletPonytail
ScarletPonytail / functions.php
Last active June 8, 2017 14:13
WordPress - Register menus in functions.php
// Register Menus
function register_my_menus() {
register_nav_menus(
array(
'header' => __( 'Header' ),
'footer' => __( 'Footer' )
)
);
}
add_action( 'init', 'register_my_menus' );
@ScarletPonytail
ScarletPonytail / functions.php
Last active June 8, 2017 14:13
Wordpress - Remove WordPress-flavoured classes from WP Menu
// Purge WP-flavoured classes on the WP Menu
add_filter('nav_menu_item_id', 'clear_nav_menu_item_id', 10, 3);
function clear_nav_menu_item_id($id, $item, $args) {
return "";
}
add_filter('nav_menu_css_class', 'clear_nav_menu_item_class', 10, 3);
function clear_nav_menu_item_class($classes, $item, $args) {
return array();
}
@ScarletPonytail
ScarletPonytail / functions.php
Created March 8, 2017 11:52
Wordpress - Add Google Analytics
// Add Google Analytics to Footer
function add_google_analytics() {
echo '<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>';
echo '<script type="text/javascript">';
echo 'var pageTracker = _gat._getTracker("UA-XXXXX-X");';
echo 'pageTracker._trackPageview();';
echo '</script>';
}
add_action('wp_footer', 'add_google_analytics');
@ScarletPonytail
ScarletPonytail / footer-category-inc-sub-list.phtml
Last active June 8, 2017 14:13
Magento - Add dynamic list of top level categoies
@ScarletPonytail
ScarletPonytail / view.phtml
Created March 10, 2017 15:06
Magento - Remove additional <br> in short description
<!-- File Path: app/design/frontend/rwd/default/template/catalog/product/view.phtml -->
<!-- Replace this... -->
<?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?>
<!-- ...with this -->
<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>