Skip to content

Instantly share code, notes, and snippets.

View anilmeena's full-sized avatar

Anil Meena anilmeena

View GitHub Profile
@anilmeena
anilmeena / display-collection-image-outside-collection-page.txt
Created October 9, 2016 08:51
Display collection image outside of collection page
// Display collection image outside of collection page
{% assign collection = collections.my-collection-handle %}
{% if collection.image %}
<img src="{{ collection.image.src | collection_img_url: 'original' }}" alt="{{ collection.image.alt }}" />
{% endif %}
@anilmeena
anilmeena / get-pages-title-content-handle.txt
Created October 15, 2016 15:59
Get a Page’s Title, Content and More With The Handle
/* Get a Page’s Title, Content and More With The Handle */
/* Method 1 */
{{ pages['about-us'].title }}
{{ pages['about-us'].content }}
/* Method 2 */
{% assign my_var = "about-us" %}
{{ pages[my_var].title }}
{{ pages[my_var].content }}
@anilmeena
anilmeena / multilevel-navigation-menu-shopify.txt
Created October 15, 2016 16:01
Multilevel Navigation Menu in Shopify
<ul class="horizontal unstyled clearfix">
{% for link in linklists.main-menu.links %}
{% if linklists[link.handle] == empty %}
<li>
<a href="{{ link.url }}" class="{% if link.active %} current{% endif %}">
<span>{{ link.title }}</span></a>
</li>
{% else %}
<!-- Menu level 1 -->
<li class="dropdown"><a href="{{ link.url }}" class="{% if link.active %} current{% endif %}">
@anilmeena
anilmeena / multiple-navigation-menu-shopify
Created October 15, 2016 16:06
Multiple Navigation Menu in Shopify
<nav role="navigation">
<ul>
{% for link in linklists.main-menu.links %}
{% assign child_list_handle = link.title | handle %}
{% if linklists[child_list_handle] and linklists[child_list_handle].links.size > 0 %}
<li class="has-dropdown">
{{ link.title | link_to: link.url }}
<ul>
{% for child_link in linklists[child_list_handle].links %}
{% assign grand_child_list_handle = child_link.title | handle %}
@anilmeena
anilmeena / adding-custom-options-existing-widgets.php
Created October 16, 2016 15:06
Adding Custom Options to Existing Widgets
<?php
/* Displaying a Custom Widget Option */
function thmfdn_add_menu_description_option( $widget, $return, $instance ) {
// Are we dealing with a nav menu widget?
if ( 'nav_menu' == $widget->id_base ) {
// Display the description option.
$description = isset( $instance['description'] ) ? $instance['description'] : '';
?>
@anilmeena
anilmeena / add-custom-column-custom-post-type.php
Created October 21, 2016 03:00
Add custom column in custom post type
<?php
// Add custom column in custom post type (here custom_post = latest_at_sonic)
add_filter( 'manage_edit-latest_at_sonic_columns', 'my_edit_latest_at_sonic_columns' ) ;
function my_edit_latest_at_sonic_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Title' ),
@anilmeena
anilmeena / add-custom-fields-wordpress-category.php
Created October 21, 2016 03:04
Add Custom Fields in Wordpress Category
<?php
/* Add Custom Fields in Wordpress Category */
// Add term page
function tutorialshares_taxonomy_add_new_meta_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="term_meta[custom_term_meta]"><?php _e( 'Example meta field', 'tutorialshares' ); ?></label>
<input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value="">
<p class="description"><?php _e( 'Enter a value for this field','tutorialshares' ); ?></p>
@anilmeena
anilmeena / add-custom-fields-wordpress-post-category
Created October 21, 2016 03:10
Add Custom Fields in Wordpress Post Category
<?php
/* Add Custom Fields in Wordpress Post Category */
// the option name
define('MY_CATEGORY_FIELDS', 'my_category_fields_option');
// your fields (the form)
add_filter('edit_category_form', 'my_category_fields');
function my_category_fields($tag) {
$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
@anilmeena
anilmeena / avoid-browser-popup-blockers.html
Created October 22, 2016 02:52
Avoid browser popup blockers
/* Pseudo code with Javascript snippets: */
// Immediately create a blank popup on user action
var importantStuff = window.open('', '_blank');
// Optional: add some "waiting" info message. Examples:
// a) An external HTML page: replace the above line with
var importantStuff = window.open('http://example.com/waiting.html', '_blank');
// b) Text: add the following line below the above one:
@anilmeena
anilmeena / jquery-datepicker-onselect-event-get-class.html
Created October 23, 2016 10:37
jQuery Datepicker onSelect event get class
(function ($) {
$(document).ready(function () {
$("#calendar").datepicker({
dateFormat: 'yyyy-mm-dd',
beforeShowDay: function (date) {
return [true, 'reserved', 'this date reserved'];
},
onSelect: function (date, el) {
var day = el.selectedDay,
mon = el.selectedMonth,