Last active
August 29, 2015 14:16
-
-
Save MLnick/a70f5cc137538f63eb3b to your computer and use it in GitHub Desktop.
Custom Graphflow Shortcode using Code Snippets Plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_shortcode('graphflow_shortcode_demo', 'graphflow_shortcode_demo_display'); | |
function graphflow_shortcode_demo_display($attr) { | |
ob_start(); | |
if ( isset( $_REQUEST['cat'] ) ) { | |
$cat_id = $_REQUEST['cat']; | |
$term = get_term_by( 'id', $cat_id, 'product_cat', 'ARRAY_A' ); | |
$cat_name = $term['name']; | |
echo do_shortcode( '[graphflow_recommendations title="Recommended for you in ' . $cat_name . '" columns=4 per_page=4 product_cat=' . $cat_id . ']' ); | |
} else { | |
echo do_shortcode( '[graphflow_recommendations columns=4 per_page=4]' ); | |
} | |
echo '<form id="category-select" class="category-select" action="' . esc_url( home_url( '/' ) ) . '" method="get">'; | |
wp_dropdown_categories( array( 'taxonomy' => 'product_cat' ) ); | |
echo '<input type="submit" name="submit" value="Get Recommendations in Category"/><input type="hidden" name="page_id" value="6774" /></form>'; | |
return ob_get_clean(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment