Skip to content

Instantly share code, notes, and snippets.

{
"buttons": {
"preorder": {
"if": "product.tags contains preorder",
"href": "#!modal-preorder",
"text": "Request it"
},
"product_buy": {
"if": "product.available == true",
"href_liquid": "'#!buy-' | append: product.variants[0].id",
@danielpataki
danielpataki / custom-loop.php
Last active July 8, 2020 20:36
Retrieve Any Post You Want With WP_Query
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'future'
);
$scheduled = new WP_Query( $args );
if ( $scheduled->have_posts() ) :
?>
<?php while( $scheduled->have_posts() ) : $scheduled->the_post() ?>
@fgilio
fgilio / wp-update_post-on-save_post.php
Last active April 17, 2024 22:34
WordPress - Update post programmatically when a post is saved
<?php
function update_on_post_saved( $post_id ) {
if ( wp_is_post_revision( $post_id ) ) return;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
// if ('NNN' !== $_POST['post_type']) return; return if post type is not NNN
// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'update_on_post_saved');
@hhayrapetyan
hhayrapetyan / related-products.liquid
Last active May 22, 2019 16:39
Shopify Venture Theme Related products snippet
@Lego2012
Lego2012 / automatically-display-titles-on-category-and-tag-archives.php
Last active April 28, 2021 12:41
Automatically display titles on Category and Tag Archives #wordpress
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
/**
* Default Category Title
*
* @author Bill Erickson
* @url http://www.billerickson.net/default-category-and-tag-titles
*
* @param string $headline
@bmodena
bmodena / shopify-discount-from-cookie.js
Last active May 2, 2019 10:08
Add discount code to checkout from URL
<?php
//hierarchical
//hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 );
//create a custom taxonomy name it topics for your posts
function create_topics_hierarchical_taxonomy() {
@igorbenic
igorbenic / admin.js
Last active September 2, 2021 12:29
Extending the WordPress Media Uploader: Custom Tab | http://ibenic.com/extending-wordpress-media-uploader-custom-tab
var Library = wp.media.controller.Library;
var oldMediaFrame = wp.media.view.MediaFrame.Post;
// Extending the current media library frame to add a new tab
wp.media.view.MediaFrame.Post = oldMediaFrame.extend({
initialize: function() {
// Calling the initalize method from the current frame before adding new functionality
oldMediaFrame.prototype.initialize.apply( this, arguments );
@minionmade
minionmade / Feature Multiple Collections & Products on Shopify Using Link List
Last active May 26, 2022 18:32
Feature Multiple Collections & Products on Shopify Using Link List
<?php
$args = array(
'label' => '', // Text in Label
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post meta where id is the meta_key
'id' => '', // required
'name' => '', //name will set from id if empty