Skip to content

Instantly share code, notes, and snippets.

@alwayscoding
alwayscoding / bootstrap.html
Created March 5, 2013 08:08
HTML: BOOTSTRAP SDK LOAD
<!-- Twitter Bootstrap SDK Load -->
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap.js"></script>
<!-- End of Twitter Bootstrap SDK Load -->
@alwayscoding
alwayscoding / gist:5088970
Last active December 14, 2015 12:48
WORDPRESS: JS REGISTER/ENQUE
function XX_scripts_with_jquery() {
wp_register_script( 'XX-script',get_template_directory_uri().'/bootstrap/js/bootstrap.js',array('jquery'));
wp_enqueue_script( 'XX-script' );
}
add_action('wp_enqueue_scripts','XX_scripts_with_jquery');
@alwayscoding
alwayscoding / gist:5089136
Created March 5, 2013 09:46
WORDPRESS: LOOP
<?php get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php get_footer(); ?>
@alwayscoding
alwayscoding / gist:5089921
Created March 5, 2013 12:12
WORDPRESS: NAVWALK
<?php
/**
* Class Name: twitter_bootstrap_nav_walker
* GitHub URI: https://github.com/twittem/wp-bootstrap-navwalker
* Description: A custom Wordpress nav walker to implement the Twitter Bootstrap 2 (https://github.com/twitter/bootstrap/) dropdown navigation using the Wordpress built in menu manager.
* Version: 1.2.2
* Author: Edward McIntyre - @twittem
* Licence: WTFPL 2.0 (http://sam.zoy.org/wtfpl/COPYING)
*/
@alwayscoding
alwayscoding / gist:5134492
Last active December 14, 2015 19:09
WORDPRESS: GET CATEGORY SLUG
<?php
if(is_category()) {
$category = get_query_var('cat');
$current_cat = get_category($cat);
echo 'The slug is ' . $ current_cat->slug;
}
?>
@alwayscoding
alwayscoding / gist:5135112
Created March 11, 2013 15:38
WORDPRESS: TAGS IN A CATEGORY
query_posts('category_name=category-slug');
if (have_posts()) :
while (have_posts()) : the_post();
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
$all_tags_arr[] = $tag->name; //USING JUST $tag MAKING $all_tags_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique
}
@alwayscoding
alwayscoding / gist:5141622
Created March 12, 2013 09:47 — forked from sjwilliams/gist:3903157
SHORTCUT: SUBLIMETEXT2

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘KB toggle side bar
⌘⇧P command prompt
⌃ ` python console
⌘⇧N new window (useful for new project)
@alwayscoding
alwayscoding / gist:5142352
Last active March 12, 2018 16:16
WORDPRESS:GET ALL TAGS FROM A CATEGORY
//FUNCTION FILE
function get_category_tags($args) {
global $wpdb;
$tags = $wpdb->get_results
("
SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link
FROM
wp_posts as p1
LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID
LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id
@alwayscoding
alwayscoding / gist:5150469
Last active December 14, 2015 21:19
STYLE: WRAP FLOAT ELEMENT
#box {
position: relative;
border: 1px solid #E0E0E0;
}
#box:before, #box:after {
display: block;
content: "";
clear: both;
}