Skip to content

Instantly share code, notes, and snippets.

View Narga's full-sized avatar

Nguyễn Đình Quân Narga

View GitHub Profile
@Narga
Narga / hide-wordpress-stats-smiley.css
Created June 6, 2012 08:28
Hide WordPress.com Stats Smiley Face
img#wpstats{width:0px;height:0px;padding:0px;border:none;overflow:hidden}
/* If you are using THESIS, just head to custom.css and paste in */
.custom img#wpstats{width:0px;height:0px;padding:0px;border:none;overflow:hidden}
@Narga
Narga / wordpress-list-most-recent-comments.php
Created June 7, 2012 02:05
Wordpress - List most recent comments
<?php
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,30) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 10";
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
$output .= "n<ul>";
foreach ($comments as $comment) {
$output .= "n<li>".strip_tags($comment->comment_author) .":" . "<a href="" . get_permalink($comment->ID)."#comment-" . $comment->comment_ID . "" title="on ".$comment->post_title . "">" . strip_tags($comment->com_excerpt)."</a></li>";
}
@Narga
Narga / wordpress-list-most-recent-post.php
Created June 7, 2012 02:07
Wordpress - List most recent posts
<?php query_posts('showposts=5'); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>
@Narga
Narga / wordpress-naviation-listing.php
Created June 7, 2012 02:23
Wordpress - Navigation Listing
<ul id="nav">
<?php wp_list_categories('title_li=&sort_column=menu_order'); ?>
</ul>
# You might also want to include a home link. You can add this manually like so:
<ul id="nav">
<li><a href="<? bloginfo('siteurl'); ?>">Home</a></li>
<?php wp_list_categories('title_li=&sort_column=menu_order'); ?>
</ul>
@Narga
Narga / wordpress-naviation-listing.html
Created June 7, 2012 02:26
Wordpress - Navigation Listing HTML Code
<ul class="menu">
<li class="cat-item cat-item-6"><a href="http://localhost/wordpress/category/long-category/" title="View all posts filed under Long Category">Long Category</a>
<ul class='children'>
<li class="cat-item cat-item-7"><a href="http://localhost/wordpress/category/long-category/sub-long-category/" title="View all posts filed under Sub Long Category">Sub Long Category</a></li>
</ul>
</li>
<li class="cat-item cat-item-1"><a href="http://localhost/wordpress/category/uncategorized/" title="View all posts filed under Uncategorized">Uncategorized</a>
<ul class='children'>
<li class="cat-item cat-item-4"><a href="http://localhost/wordpress/category/uncategorized/subcategories/" title="View all posts filed under SubCategories">SubCategories</a></li>
<li class="cat-item cat-item-3"><a href="http://localhost/wordpress/category/uncategorized/subcategorized/" title="View all posts filed under Subcategorized">Subcategorized</a></li>
@Narga
Narga / wordpress-dropdown-naviation.css
Created June 7, 2012 02:27
Wordpress - Dropdown Navigation CSS Code
ul.menu { list-style: none outside none; padding: 0; margin: 0 10px; float: left; font-size: 13px;}
ul.menu li { float: left; margin: 0; padding: 0 15px 0 0; position: relative; }
ul.menu li a { padding: 9px 5px; color: rgb(255, 255, 255); display: block; text-decoration: none; float: left; display: block;}
ul.menu li:hover { background: #A6CB1B; }
.current-cat { background: #8BBF47; }
ul.menu li span { width: 11px; height: 10px; float: left; background: url('images/narga-sprites.png') -561px -78px no-repeat; margin: 11px 0 0 0;}
ul.menu li ul.children {z-index:99; list-style: none outside none; position: absolute; left: 0; top: 31px; background: none repeat scroll 0% 0% rgb(51, 51, 51); margin: 0; padding: 0; display: none; float: left; width: 170px; border-bottom: 1px solid #F8C92D;}
ul.menu li ul.children li { margin: 0; padding: 0; clear: both; width: 170px; border-top: 1px solid #F8C92D;}
html ul.menu li ul.children li a { float: left; width: 145px; background: url('images/narga-sprites.png') -
@Narga
Narga / wordpress-dropdown-naviation.js
Created June 7, 2012 02:28
Wordpress - Dropdown Navigation jQuery Code
if(!jQuery.browser.msie){jQuery("ul.topnav").css({opacity:"0.95"});} // IE - 2nd level Fix
jQuery(".topnav > li > ul").css({display: "none"}); // Opera Fix
jQuery("ul.sub-menu").parent().append("<div>&nbsp;</div>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
jQuery("ul.sub-menu li.menu-item").append("<span>&#187;</span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
jQuery("ul.menu li a").hover(function() { //When trigger is clicked...
//Following events are applied to the subnav itself (moving subnav up and down)
jQuery(this).parent().find("ul.sub-menu").slideDown('fast').show(400); //Drop down the subnav on hover
jQuery(this).parent().hover(function() {
}, function(){
jQuery(this).parent().find("ul.sub-menu").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
@Narga
Narga / simple-signup-form.html
Created June 7, 2012 02:38
Simple Signup Form
//http://www.narga.net/making-awesome-forms-inline-labels-with-jquery
<form id="signup" name="signup">
<label for="email">Email Address</label>
<input class="text" name="email" type="text" />
<label for="username">Username</label>
<input class="text username" name="username" type="text" />
<input class="btn" type="submit" value="Sign Up" />
</form>
@Narga
Narga / jquery-choose-mouse-position.js
Created June 7, 2012 02:40
jQuery script to choose the mouse cursor position when I click on input field
//http://www.narga.net/making-awesome-forms-inline-labels-with-jquery
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
@Narga
Narga / jquery-hide-label-element.js
Created June 7, 2012 02:43
jQuery - loop through label elements then hide
//http://www.narga.net/making-awesome-forms-inline-labels-with-jquery
$("#signup label").each(function (i) {
$(this).next("input").attr("value",$(this).html()+"..."
$(this).hide();
});