• Resolved peer1979

    (@peer1979)


    This is very strange an i’m unable to solve it right now. Code underneath used to work, but now it fails. I suspect it fails because of recent updates of WordPress / Woocommerce.

    I want to achieve a custom description on my woocommerce category pages. The field ‘alt_page_title’ contains a specifc title for this content.

    Now the function gets called but term_description() returns null. Inside term_description() i can see a loaded WP_term object with a term_id, name and slug but an empty description field. I’ve also tried the function category_description() and a custom ACF description field. Nothing seems to return anything.

    I’ve noticed that not only woocommerce / wordpress functions fails, but also ACF on these woocommerce categories.

    Hooks:
    
    remove_action('woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10);
    add_action('woocommerce_archive_description', array('\MyCustomWoocommerce\libraries\Categories', 'description'));
    

    Method description

    public static function description()
        {
            if(is_tax(array('product_cat', 'product_tag')))// && 0 === absint(get_query_var('paged')))
            {
                $description = wc_format_content(term_description());
                if($description)
                {
                    $postID = self::get_acf_postID();
                    $alt_page_title = get_field('alt_page_title', $postID);
                    $descriptionTitle = $alt_page_title ? $alt_page_title : woocommerce_page_title(false);
    
                    echo '<section class="category_description">';
                    echo '<h2>' . $descriptionTitle . '</h2>';
                    echo '<div>' . $description . '</div>';
                    echo '</section>';
                }
            }
        }
Viewing 1 replies (of 1 total)
  • Thread Starter peer1979

    (@peer1979)

    Fixed and OMG…

    I was working on a dev machine and looked at the staging environment. Need a brake ??

Viewing 1 replies (of 1 total)
  • The topic ‘Category > can’t get description and other info anymore (used to work)’ is closed to new replies.