Jump to content

Archived

This topic is now archived and is closed to further replies.

gabelloyd

Flipper for Custom Post Types

Recommended Posts

gabelloyd

http://paste.pagelines.com/JXmB1ORq

 

This applies for WooCommerce, but also for any custom_post_type. 

 

In Flipper, the default allows us to choose a post_type.  Flipper does this by get_post_types, creates and array and then makes that array available to us in the drop down selection.  Let's say I want to set the post type, and then create the array of the taxonomy(ies) under that post type.  My drop down menu would then be populated with the taxonomy(ies) of this specific post type that I've set in my new section file.  

 

Now that we know what I want to do...

 

The documentation for "Select Taxonomy" (ref:  http://docs.pagelines.com/developer/dms-option-engine ) states:

"To create an option that allows users to select a taxonomy (i.e. category) for a specific post type, just use these attributes:"

 

and shows: 

$opts[] = array(
            'key'           => 'some_key',
            'type'          => 'select_taxonomy',
            'post_type'     => 'post' // the post type to grab taxonomies from
        );

Now that we've set that background up:  what is the "key" here?  Is the key my post_type or do I set the key somewhere else?  The default is set to "flipper_post_type".  

 

I've posted an attempt in pastebin above.  

 

Thanks in advance.

Share this post


Link to post
Share on other sites
gabelloyd

Yeah, but I'd rather not have to require the client to enter meta data for every custom post type.  If I set the post_type and know the taxonomy(ies) and slug(s) that I would like to show in the drop down, I should be able to create a new Flipper section, right?  Again, set the product so that the drop down becomes the available taxonomies or slugs.

 

Do I need to change the "key" element?  It's set to "flipper_post_type" in the default, so does this change or remain the same when creating new sections?

 

Thanks!

Share this post


Link to post
Share on other sites
gabelloyd

I did try the shortcodes in the Flipper Meta section, just to see if I could specify the product category that I'm trying to target, but it didn't seem to work.  The I assume I can use the shortcodes from WooCommerce for this?

 

So, back to the dropdown of sub-catgeories in a custom Flipper Section, I just wanted to check to make sure I'm focusing on the right area of the functions here.  

 

Reference of terms that we are working with here:

 

(from URL string:  taxonomy=product_cat&tag_ID=55&post_type=product)

custom_post_type  = product

taxonomy = product_cat

slug = (determined by drop down selection, but looking here for 'certified' or term_ID of 55)  (which is the KEY that I was asking about earlier)

 

In my custom flipper section, this works: 

if($this->opt('flipper_post_type') == 'post'){
			$selection_opts[] = array(
				'label'			=> 'Post Category',
				'key'			=> 'flipper_category', 
				'type'			=> 'select_taxonomy', 
				'post_type'		=> 'post', 
				'help'		=> __( 'Only applies for standard blog posts.', 'pagelines' ),
			); 
		}
		
		elseif ($this->opt('flipper_post_type') == 'product') {
			$selection_opts[] = array(
				'label'			=> 'Product Category',
				'key'			=> 'flipper_category', 
				'type'			=> 'select_taxonomy', 
				'post_type'		=> 'product', 
				'help'		=> __( 'Only applies for products.', 'pagelines' ),
			); 

		}

It seems that farther down the file, the actual execution of the function takes place.  I've been unable to get the dropdown to display the sub-categories of the products.  Most recently I've referenced these articles to help, but to no avail:

 

How we would create a custom_post_type dropdown menu without Pagelines:  http://wordpress.stackexchange.com/questions/1236/custom-post-type-taxonomy-dropdown-menu

<?php $tax = get_object_taxonomies('TAXONOMY_NAME');
$taxterms = get_terms( $tax, 'orderby=count&offset=1&hide_empty=0&fields=all' );
?>

foreach ( $taxterms as $term ) { 
        echo '<option value="' . $term->slug . '" selected>' . $term->name . '</option>',"\n"; 
    } ?>

Checking difference between is_product_category and in_product_category (you can use 'has_term') http://wordpress.org/support/topic/plugin-woocommerce-excelling-ecommerce-is_product_category-vs-in_product_category?replies=4

Stackexchange for getting top level parent for WooComm:  http://wordpress.stackexchange.com/questions/24794/get-the-the-top-level-parent-of-a-custom-taxonomy-term

WooCommerce is_product: http://docs.woothemes.com/wc-apidocs/function-is_product_category.html

And I checked out Ellen's WooCommerce for Pagelines sections:  https://github.com/bearded-avenger/pagelines-woocommerce/blob/master/pagelines-woocommerce.php to see how she's calling product information. 

 

 

Just to be clear, the Products DO SHOW, but I want to filter the Products by category and allow the client to have this filtering ability.  

 

I know the function for regular post filtering is this:

if ('flipper_post_type' == 'post') {
		
		if( $this->opt('flipper_category') && $this->opt('flipper_category') != '' ){
			$cat = get_category_by_slug( $this->opt('flipper_category') ); 
			$the_query['category'] = $cat->term_id;
		}

but when I do something like this, it doesn't work:

}  elseif ('flipper_post_type' == 'product') {

		if( $this->opt('flipper_category') && $this->opt('flipper_category') != '' ){
			
			$term = has_term( 'flipper_category', 'product_cat' );
			
			$the_query['category'] = $term->term_id;
			
			}
		}

Thanks for any help.

Share this post


Link to post
Share on other sites

  • Similar Content

    • Jessica McCabe Lawson
      By Jessica McCabe Lawson+
      I'm building a product catalog site. The featured image is set correctly, but the woocommerce placeholder image is displaying instead. If I click on the placeholder image, the featured image appears, and the featured image works fine as a thumbnail.
      Please view the site here: http://www.directmat.net/product/power-lock-logo-mat/
      Note: I deleted the placeholder image via FTP to see if that would inspire Quick Shop to look for the featured image. No such luck. Please help!
    • mtaus
      By mtaus+
      I'm using Woocommerce in a Pagelines framework. When I build out a product, I'm able to add images in the admin panel and the
      Product Image will display on Shop page, but neither the Product Image nor the Product Gallery will display on the product's dedicated page.
      Shop: https://bendbotanics.com/shop/
      Product Example: https://bendbotanics.com/product/500mg-full-spectrum-hemp-oil-fsho/
      Any help would be greatly appreciated!
    • cdracos
      By cdracos+
      Hello everyone,
      I face a common problem as I can see on relevant topics with quickshop plugin. 
      On Product Single page of woocommerce, i use quickshop as layout. The primary photo of my product doesn't appear on the thumb slider, but the first image is the default placeholder. 
      Need some help not with custom script in the product description for each product. 
      Have a look on my website: http://lillyandsid.gr/shop/camp-things-top/
    • stijnxo
      By stijnxo+
      I am using the Powerloop plug-in on my DMS website and can sort my elements by Postdate, but I want to sort the pages in Alphabetic order.
      Actually the same question for sorting Flipper content in Alphabetic order instead of Ascending / Descending / Random options.
    • bnapoli
      By bnapoli+
      I have Quickshop installed on my WooCommerce section of this website: http://a04.125.myftpupload.com/
      Main Shop: http://a04.125.myftpupload.com/?page_id=1198
      I've having what appears to be CSS issues on the individual product pages. After cleaning up any code accessible from the wp-admin, the page still appears broken. I never tried to customize it, it just came broken like this right out of the box.
      You can see examples of it broken on every single product page, see here:
      http://a04.125.myftpupload.com/?product=futaba-14sg-14-channel-2-4-ghz-radio-system
      http://a04.125.myftpupload.com/?product=gremsy-gstabi-h7-brushless-3-axis-gimbal
      http://a04.125.myftpupload.com/?product=dji-inspire-1-zenmuse-x5-gimbal-and-camera-unit
      http://a04.125.myftpupload.com/?product=dji-wookong-m-flight-controller
      Can somebody help?
×