Jump to content


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


Flipper for Custom Post Types

Recommended Posts




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

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?



Share this post

Link to post
Share on other sites

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

    • 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:
      Can somebody help?
    • King Creative Design
      By King Creative Design+
      I am setting up a Woocommerce site using PL Framework and Platform 5. I added a hook so the category description appears under the category page titles (on archive pages). However, it also appears under the title on the main "shop" page (which I have renamed "Catelog" page). There is a default description here and I can't figure out for the life of me where it is being generated from so I can change it. Any ideas how to change it or delete it on the main shop page ONLY? The staging site is here - http://16e.117.myftpupload.com/ and the page in question is http://16e.117.myftpupload.com/catalog/
      I have hit up Woocommerce support and they weren't familiar with Platform 5 and recommended I contact you.
      Your help would be appreciated, thanks!

    • DonRicardoRVM
      By DonRicardoRVM+
      First of all, sorry for my bad english.
      I have a shop with Woocommerce, platform-5 and PL Quicshop, and it´s all OK, but there is a prloblem: in the category page product I don´t get dosplay the bubble "price" when the product is in sale. 
      This is my product category page, without the bubble: https://globosdemar.com/categoria-producto/collares/
      And this is othrer shop with the bubble: https://www.usaprocom.com/product-category/fireplace-systems/
      Somebody knows how solve this?
    • hibbsy78
      By hibbsy78+
      Anyone having issues with Apple Pay & woocommerce? Before I start with trying to disable plugins one by one I thought I'd check here first!
      I'm having issues with the payment processing part which just times out?