- This topic has 44 replies, 3 voices, and was last updated 1 year, 3 months ago by
Tom.
-
AuthorPosts
-
November 24, 2019 at 2:50 pm #1075266
sparkle
i’m setting it to contain just your code in my functions file. but here are the other functions i had.
<?php /** * GeneratePress child theme functions and definitions. * * Add your custom PHP in this file. * Only edit this file if you have direct access to it on your server (to fix errors if they happen). */ function generatepress_child_enqueue_scripts() { if ( is_rtl() ) { wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' ); } } add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 ); // Enqueue Google Fonts. function wpb_add_google_fonts() { wp_enqueue_style( 'wpb-google-fonts', 'https://fonts.googleapis.com/css?family=Aclonica|Catamaran|Krona+One', false ); } add_action( 'wp_enqueue_scripts', 'wpb_add_google_fonts' ); add_action( 'wp_enqueue_scripts', 'tu_load_font_awesome' ); // Enqueue Font Awesome. function tu_load_font_awesome() { wp_enqueue_style( 'font-awesome', '//use.fontawesome.com/releases/v5.3.1/css/all.css', array(), '5.3.1' ); } // Use ACF with Elementor. define ('ACF_EARLY_ACCESS', '5'); // Change number of products that are displayed per page (shop page) add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 21); function new_loop_shop_per_page( $cols ) { // $cols contains the current number of products per page based on the value stored on Options -> Reading // Return the number of products you wanna show per page. $cols = 21; return $cols; } // html in excerpts function wpse_allowedtags() { // Add custom tags to this string return '<script>,<style>,<br>,<em>,<i>,<ul>,<ol>,<li>,<a>,<p>,<img>,<video>,<audio><h2><h3>'; } if ( ! function_exists( 'wpse_custom_wp_trim_excerpt' ) ) : function wpse_custom_wp_trim_excerpt($wpse_excerpt) { $raw_excerpt = $wpse_excerpt; if ( '' == $wpse_excerpt ) { $wpse_excerpt = get_the_content(''); $wpse_excerpt = strip_shortcodes( $wpse_excerpt ); $wpse_excerpt = apply_filters('the_content', $wpse_excerpt); $wpse_excerpt = str_replace(']]>', ']]>', $wpse_excerpt); $wpse_excerpt = strip_tags($wpse_excerpt, wpse_allowedtags()); /*IF you need to allow just certain tags. Delete if all tags are allowed */ //Set the excerpt word count and only break after sentence is complete. $excerpt_word_count = 75; $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); $tokens = array(); $excerptOutput = ''; $count = 0; // Divide the string into tokens; HTML tags, or words, followed by any whitespace preg_match_all('/(<[^>]+>|[^<>\s]+)\s*/u', $wpse_excerpt, $tokens); foreach ($tokens[0] as $token) { if ($count >= $excerpt_length && preg_match('/[\,\;\?\.\!]\s*$/uS', $token)) { // Limit reached, continue until , ; ? . or ! occur at the end $excerptOutput .= trim($token); break; } // Add words to complete sentence $count++; // Append what's left of the token $excerptOutput .= $token; } $wpse_excerpt = trim(force_balance_tags($excerptOutput)); $excerpt_end = ' <a href="'. esc_url( get_permalink() ) . '">' . ' » ' . sprintf(__( 'Read more about: %s »', 'wpse' ), get_the_title()) . '</a>'; $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); //$pos = strrpos($wpse_excerpt, '</'); //if ($pos !== false) // Inside last HTML tag //$wpse_excerpt = substr_replace($wpse_excerpt, $excerpt_end, $pos, 0); /* Add read more next to last word */ //else // After the content $wpse_excerpt .= $excerpt_more; /*Add read more in new paragraph */ return $wpse_excerpt; } return apply_filters('wpse_custom_wp_trim_excerpt', $wpse_excerpt, $raw_excerpt); } endif; remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('get_the_excerpt', 'wpse_custom_wp_trim_excerpt'); // Move Secondary Nav add_action( 'after_setup_theme', 'lh_move_secondary_nav' ); function lh_move_secondary_nav() { remove_action( 'generate_before_header', 'generate_add_secondary_navigation_before_header', 7 ); add_action( 'generate_inside_navigation', 'generate_add_secondary_navigation_before_header', 7 ); } // Add CPTs to author archives function custom_post_author_archive($query) { if ($query->is_author) $query->set( 'post_type', array('portfolio', 'post') ); remove_action( 'pre_get_posts', 'custom_post_author_archive' ); } add_action('pre_get_posts', 'custom_post_author_archive'); // default images for social media - url fallback required function jeherve_custom_image( $media, $post_id, $args ) { if ( $media ) { return $media; } else { $permalink = get_permalink( $post_id ); $url = apply_filters( 'jetpack_photon_url', 'https://thebridgebrothers.com/wp-content/uploads/2019/01/Flipped.jpg' ); return array( array( 'type' => 'image', 'from' => 'custom_fallback', 'src' => esc_url( $url ), 'href' => $permalink, ) ); } } add_filter( 'jetpack_images_get_images', 'jeherve_custom_image', 10, 3 ); // Remove Default Category (UNCATEGORIZED from Woocommerce Catalog add_filter( 'woocommerce_product_subcategories_args', 'custom_woocommerce_product_subcategories_args' ); function custom_woocommerce_product_subcategories_args( $args ) { $args['exclude'] = get_option( 'default_product_cat' ); return $args; } //Add clear cart button on checkout page // check for empty-cart get param to clear the cart add_action( 'init', 'woocommerce_clear_cart_url' ); function woocommerce_clear_cart_url() { global $woocommerce; if ( isset( $_GET['empty-cart'] ) ) { $woocommerce->cart->empty_cart(); } } add_action( 'woocommerce_cart_actions', 'patricks_add_clear_cart_button', 20 ); function patricks_add_clear_cart_button() { echo "<a class='button' href='?empty-cart=true'>" . __( 'Empty Cart', 'woocommerce' ) . "</a>"; } // ENABLE SHORTCODES IN CONTACT FORM 7 add_filter( 'wpcf7_form_elements', 'do_shortcode' ); // turn off admin email check add_filter( 'admin_email_check_interval', '__return_false' ); // woo change # of images in row by category add_filter( 'option_generate_woocommerce_settings', 'tu_custom_wc_columns' ); function tu_custom_wc_columns( $options ) { if ( is_product_category( 'apparel' ) ) { $options['columns'] = 6; } return $options; }
i’m heading out for the evening but will be back tomorrow to keep trying.
November 24, 2019 at 4:14 pm #1075319Leo
StaffCustomer SupportIs the function still added?
Can you make sure it’s the only added function for now?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/November 24, 2019 at 7:53 pm #1075408sparkle
yes. it’s the only function in the file.
November 25, 2019 at 6:13 am #1076070sparkle
hm, it may or may not be related that the menu in the woocommerce pages are now truncated and the icon buttons don’t show.
November 25, 2019 at 10:07 am #1076674Tom
Lead DeveloperLead DeveloperLet’s test that conditional quick..
add_action( 'generate_before_header', function() { if ( is_product_category( 'apparel' ) ) { echo 'hi'; } } );
Does this function add the text “hi” above your header in the apparel category?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 25, 2019 at 10:59 am #1076753sparkle
yes, it does. π
November 25, 2019 at 11:24 am #1076795sparkle
(also i fixed something that brought the icons back)
November 25, 2019 at 5:20 pm #1077179Tom
Lead DeveloperLead DeveloperWeird, that code should work. Is there anything special about the category? Is it using shortcodes or anything to display the content?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 26, 2019 at 5:01 am #1077763sparkle
no. the category is populated with items from printful (print on demand) but other than that itβs just a standard archive.
November 26, 2019 at 5:40 pm #1078860Tom
Lead DeveloperLead DeveloperIf you use the columns feature in the Customizer (Customize > Layout > WooCommerce), does it do anything?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 27, 2019 at 5:45 am #1079609sparkle
yes, i can change the catalog look with the customizer. happy to give you a login if that helps, tom
November 27, 2019 at 3:10 pm #1080479Tom
Lead DeveloperLead DeveloperThat would be great, thanks!: https://generatepress.com/contact
Be sure to mention this topic π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 1, 2019 at 10:14 am #1088198sparkle
ok. i sent you the deets in the contact form. i also put back in all my functions on the development site so you can see what i had been working with. i have a back up so feel free to muck around.
December 1, 2019 at 7:46 pm #1088769Tom
Lead DeveloperLead DeveloperHi there,
Can you try activating the WooCommerce module in “Appearance > GeneratePress”?
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 2, 2019 at 5:11 am #1089405sparkle
ok. i did that and now everything is four across….
-
AuthorPosts
- You must be logged in to reply to this topic.