Skip to content

Instantly share code, notes, and snippets.

View tevashov's full-sized avatar

Teff tevashov

View GitHub Profile
@tevashov
tevashov / Asset.js
Last active October 27, 2022 21:53
Check if jQuery is Loaded #jQuery
if (typeof jQuery == 'undefined') {
    // jQuery IS NOT loaded, do stuff here.
}
@tevashov
tevashov / Asset.php
Last active October 27, 2022 21:56
Add custom post type #WP
$args = array(
'label' => __('Products'),
'singular_label' => __('Product'),
'public' => true,
'show_ui' => true,
'capability_type' => 'page',
'hierarchical' => false,
'rewrite' => true,
'query_var' => 'products',
'supports' => array('title', 'thumbnail')
@tevashov
tevashov / Asset.php
Last active October 27, 2022 21:57
Add custom post type with taxonomy #WP
function post_type_albums() {
register_post_type(
'albums',
array( 'label' => __('Albums'),
'public' => true,
'show_ui' => true,
'supports' => array('post-thumbnails', 'excerpts', 'trackbacks', 'comments')
)
);
// Custom Taxonomy for Genres: categories specific for this post type
@tevashov
tevashov / Asset.php
Last active October 27, 2022 21:56
Print custom fields #WP
<?php echo get_post_meta($post->ID, "Camera_Specs", true); ?>
@tevashov
tevashov / Asset.js
Last active April 1, 2023 02:44
jQuery latest hotlink #jQuery
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js" ></script>
@tevashov
tevashov / Asset.css
Created March 15, 2013 19:34
Styling button elements to look like links
.text {
overflow:visible; /* Shrinkwrap the text in IE7- */
margin:0;
padding:0;
border:0;
color:#8f1f08; /* Match your link colour */
background:transparent;
font:inherit; /* Inherit font settings (doesn’t work in IE7-) */
line-height:normal; /* Override line-height to avoid spacing issues */
text-decoration:underline; /* Make it look linky */
@tevashov
tevashov / Asset.php
Last active October 27, 2022 21:51
Get posts from custom tax grouped by terms (MySQL) #WP
// get a list of categories, in this case your custom taxonomy (your_taxonomy_name)
$querystr = "SELECT terms.* FROM $wpdb->term_taxonomy tax LEFT JOIN $wpdb->terms terms ON tax.term_id = terms.term_id WHERE tax.taxonomy = 'retouch_types'";
$categories = $wpdb->get_results($querystr, OBJECT);
// begin a loop through those terms (categories in your custom taxonomy)
foreach( $categories as $category ) {
echo '<div class="category-header"><h2>'.$category->name.'</h2>'; // print the cat title
echo '<p class="category-description">'.strip_tags(term_description($category->term_id,'retouch_types')).'</p></div>'; // cat description
//select posts in this category, and of a specified content type
@tevashov
tevashov / Asset.php
Last active October 27, 2022 21:55
Define WordPress custom post types #WP
if( !function_exists( 'create_quote_post_type' ) ):
function create_quote_post_type() {
$labels = array(
'name' => __( 'Quote' ),
'singular_name' => __( 'Quote' ),
'add_new' => __( 'Add quote' ),
'all_items' => __( 'All quotes' ),
'add_new_item' => __( 'Add quote' ),
'edit_item' => __( 'Edit quote' ),
'new_item' => __( 'New quote' ),
@tevashov
tevashov / Asset.css
Created March 15, 2013 19:34
Long strings truncation
.break {
-ms-word-break: break-all;
word-break: break-all;
word-break: break-word;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
@tevashov
tevashov / Asset.js
Last active October 27, 2022 21:53
Log to console via jQuery #jQuery
jQuery.fn.log = function (msg) {
console.log("%s: %o", msg, this);
return this;
};
$('#some_div').find('li.source > input:checkbox').log("sources to uncheck").removeAttr("checked");