-
AuthorPosts
-
July 9, 2016 at 11:41 am #658735
Hi Enfold-Team, i want to show the actual associated category in a posting-page.
Here i found an example with a shown tag: http://kriesi.at/themes/enfold/2014/04/19/youth-is-fun-make-sure-it-stays-that-way/ and this speaker-shopping productpage https://mo-sound.com/de/shop/kugellautsprecher-schwarz-classic/Is it possible to do this with a post category?
thanks!July 11, 2016 at 1:58 pm #659262btw, here is our website:
July 12, 2016 at 4:19 am #659654Hi,
Thank you for using Enfold.
Are you referring to the “categories” widget? Go to the Appearance > Widgets panel then add the “Categories” widget.
Best regards,
IsmaelJuly 18, 2016 at 4:55 pm #662124hi ismael, no i mean a link in the article. like “Tags: econ, lifestyle” at here http://kriesi.at/themes/enfold/2014/04/19/youth-is-fun-make-sure-it-stays-that-way/
July 21, 2016 at 4:49 am #663182Hi,
I see. Please edit the includes > loop-index.php file. Look for this code:
if(has_tag()) { echo '<span class="blog-tags minor-meta">'; the_tags('<strong>'.__('Tags:','avia_framework').'</strong><span> '); echo '</span></span>'; }
Below that line, add this:
//categories on single post if(has_category()) { echo '<span class="blog-categories minor-meta">'; echo '<strong>'.__('Categories:','avia_framework').'</strong><span> '; the_category(' '); echo '</span></span>'; }
Best regards,
IsmaelJuly 26, 2016 at 4:44 pm #665394thanks, it works well when the default editor is activated.
im sad sad to say to have to use the advanced editor. is there also a way (in the best case with my prideful child-theme)?
thanks!July 26, 2016 at 6:40 pm #665430It’s really not good looking but working.
I had the same problem with SKU and Categories, which DO appear in the default editor but not in the advanced editor, so I had to manually write them in. It creates the shortcode [display_sku_cat]. Just try it out.
Create a new .php file and put it in the plugins folder. You can just adapt it to your needs, which should be pretty easy to do. That’s coming from a php newbie who wrote this – me .. ;)<?php /* Plugin Name: Display Article Number and Categories Description: Creates a shortcode, [display_sku_cat id="n"], that displays the article number and categories of any WooCommerce product. Version: 1.0 Author: Duke Requires: PHP5, WooCommerce Plugin */ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ){ add_shortcode('display_sku_cat', 'display_sku_cat_shortcode'); } function display_sku_cat_shortcode($atts) { global $post; extract(shortcode_atts(array( 'id' => $post->ID, 'link' => 'true', ), $atts)); if($link==='true'|$link==='false') { $link = ($link === 'true'); } if(get_post_type($id)=='product'){ ob_start(); display_sku_cat($id); return ob_get_clean(); }else{ return ""; } } function display_sku_cat($id="", $permalink=false ){ global $wpdb; global $post; global $product; if(empty($id)){ $id=$post->post_id; } if(is_bool($permalink)) { if($permalink){ $link = get_permalink( $id ); } }else{ $link = $permalink; $permalink = true; } $target = ""; if($newwindow == 'true'){ $target="target='_blank' "; } if(get_post_type( $id )=='product'){ $artikelnummer = $wpdb->get_var( " SELECT COUNT(meta value) FROM $wpdb->postmeta WHERE meta_key = '_sku' AND post_id = $id "); } if ( wc_product_sku_enabled() && ( $product->get_sku() || $product->is_type( 'variable' ) ) ) : ?> <span style="font-size: 11px;"> <span class="sku_wrapper"><?php _e( 'SKU:', 'woocommerce' ); ?> <span class="sku" itemprop="sku"><?php echo ( $sku = $product->get_sku() ) ? $sku : __( 'N/A', 'woocommerce' ); ?></span></span></br > <?php endif; ?> <?php echo $product->get_categories( ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', $cat_count, 'woocommerce' ) . ' ', '</span>' ); ?> </span> <?php } ?>
- This reply was modified 8 years, 5 months ago by BierPlus.
July 26, 2016 at 6:52 pm #665432July 27, 2016 at 4:43 pm #665806thx @bierplus for sharing this! for products, only with this feature, the advanced editor is usable.
for me it is not in my opportunity-range to adapt this for post-articles. -
AuthorPosts
- You must be logged in to reply to this topic.