dynamic php menu with hidden sub-categories only showing when the category name is clicked

This is for a wordpress store and I want to show the categories names automatically, but with the sub-categories hidden, the code below works perfectly with the hover effect, now I wish to have the click effect instead. The $cats variable is to use the get_terms() function, but for here to work everywhere I had included a few categories, the categories only go so far as the “third generation”.

<?php $cats = array(array('first', 'sub-first', 'sub-sub-first'),
                    array('second', 'sub-second'),
                    array('third', 'sub-third', 'sub-sub-third')); ?>
<ul class="ul1"> <?php
  foreach($cats as $cat):
    if (isset($cat(0))): ?>
      <li class="li1" onclick="test()"><a href="#"><?php echo $cat(0) ?></a> <?php
        if (isset($cat(1))):?>
          <ul class="ul2">
            <li class="li2"><a href="#"><?php echo $cat(1) ?></a> <?php
              if (isset($cat(2))):?>
                <ul class="ul3">
                  <li class="li3"><a href="#"><?php echo $cat(2) ?></a> </li>
                </ul> <?php
              endif; ?>
          </ul> <?php
        endif; ?>
      </li> <?php
  endforeach; ?>

<style media="screen">
    list-style: none;
    text-decoration: none;
    border:1px solid lightgreen;
  .ul2, .ul3{
  .li1:hover .ul2{
  .ul2:hover .ul3{

for the click effect I had remove from the style the last two hover effects and add the javascript function test();

<script type="text/javascript">
    function test(){

What is happening is that I click a category and all sub-categories are showing, What I wanted is the same as the hover effect, that if I click the first category, I have only the sub-categories of that category and so on.

If someone could help me, I have been twisting my mind over this for a few days already!

Grothendieck group of the category of boundary conditions of topological field theory

In this paper also the journal front page, eq. 2.14, it introduces the
the Grothendieck group $K^0$ of the category of boundary conditions of topological field theory.

enter image description here

My question is that

  • what exactly is the Grothendieck group $K^0$ of the category of boundary conditions of topological field theory really mean?
  • Does this say that the boundary conditions of topological field theory can be related or classified by a Grothendieck group? Is this an abelian group or nonabelian group? ($K^0(BCondμ(M^{d−1}) )=?$)
  • Should the boundary conditions of topological field theory classified by some bimodule of certain modular tensor category? how is this related to a Grothendieck group?

Custom Post Type with Category Separate

I have create two custom post type(movie type1 , movie 2) from function.php, but when make new category, this category duplicates itself in the POSTS(Article) and other CPT(movie type1, movie2) why?

enter image description here

function custom_post_type_week() {
// Set UI labels for Custom Post Type
    $labels = array(
        'name'                => _x( 'Movie type 1', 'Post Type General Name', 'twentythirteen' ),
        'singular_name'       => _x( 'Movie type 1', 'Post Type Singular Name', 'twentythirteen' ),
        'menu_name'           => __( 'movie type 1', 'twentythirteen' ),
        'parent_item_colon'   => __( 'Parent Movie', 'twentythirteen' ),
        'all_items'           => __( 'All Movies', 'twentythirteen' ),
        'view_item'           => __( 'View Movie', 'twentythirteen' ),
        'add_new_item'        => __( 'Add New Movie', 'twentythirteen' ),
        'add_new'             => __( 'Add New', 'twentythirteen' ),
        'edit_item'           => __( 'Edit Movie', 'twentythirteen' ),
        'update_item'         => __( 'Update Movie', 'twentythirteen' ),
        'search_items'        => __( 'Search Movie', 'twentythirteen' ),
        'not_found'           => __( 'Not Found', 'twentythirteen' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'twentythirteen' ),

$args = array(
    'label'               => __( 'movies', 'twentythirteen' ),
    'description'         => __( 'Movie news and reviews', 'twentythirteen' ),
    'labels'              => $labels,
    'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
    'hierarchical'        => true,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => 'page',
    'show_in_rest'        => true,
    // This is where we add taxonomies to our CPT
    'taxonomies'          => array( 'category','post_tag' ),

register_post_type( 'movies', $args );


add_action( ‘init’, ‘custom_post_type_week’, 0 );

vlookup – Categorize text in Google Sheets based on matching partial text in the Category index

I’m looking to match, with VLOOKUP, part of the words in a column in the main sheet to an index of keywords/categories where partial words are stored for ease in another sheet.

Here’s an example worksheet:

  1. The Expenses sheet has the data as we receive it, in columns A to C.
  2. In Column D, we’d like to auto-assign a category to these expenses. If we do this with exact text in the column B, for example, BANK VISA PREAUTH PYMT, then it’s easy. The VLOOKUP formula in column D works by getting this precise reference from the ‘Categories’ tab (cell A1 is worded exactly this way). This formula works: =IFERROR(VLOOKUP(B2,Categories!A:B,2,FALSE),"")
  3. The challenge is that our expenses of a similar type won’t always follow the exact text. For example: SEND E-TFR US***ke5 and SEND E-TFR US***xja. As such, we’d like to match just the text SEND E-TFR.

This means the VLOOKUP needs to match partials in the ‘Categories’ tab first column. How does adjust the VLOOKUP formula to achieve this?

PS. My question is quite similar to this one with the vital distinction of wanting to match substrings.
Categorize cells in Google Spreadsheets

categories – How to show the category of custom taxonomy

In the built category, we can use has_category() and the_category() to show if the post has category and the name of the category.

Now, I am using my custom post type and custom taxonomy. The above two functions are invalid in this case. I wonder what’s the API to use here? Thank you.

magento2 – Need to add custom canonical url to the top of category landing page

In the Magento Backend configured custom canonical url of each category. I need to added that url in every category pages.
in this case I have to update catalog_category_view.xml.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
       <link rel="customcanonical" href="https://example.com/tea?product_list_limit=500" /> 
        <move element="category.image" destination="page.top" before="breadcrumbs" />
        <move element="page.main.title" destination="content" before="category.products" />
        <move element="category.cms" destination="content" before="category.products" />
        <referenceBlock name="product_list_toolbar">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">product/list/toolbar.phtml</argument>
        <referenceBlock name="category.image">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">category/image.phtml</argument>
        <referenceBlock name="category.description">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">category/description.phtml</argument>
            <block name="category.list.top.filters" as="navigation.filters" class="MagentoLayeredNavigationBlockNavigationState" template="Netstarter_StackNavigation::layer/ns_state.phtml"/>
        <referenceContainer name="content">
            <block class="MagentoFrameworkViewElementTemplate" name="continue.checkout.popup" template="Magento_Catalog::product/list/checkout_popup.phtml"/>

customcanonical dynamically changed according to the category.how to added dynamically custom url to the category landing page.

Thank you

magento2 – Custom category Image attribute magento 2.3+

I’ve searched alot and evrywhere the code has to go through many plugins and need of adding routers to add custom image attribute for category. I’ve added a code below to add custom image attribute which is completely hassel-free and hope it helps someone.

Note: It’s tested and verified on Magento 2.3.5

Considering the module exists already

  1. Add image attribute install code to setup




namespace VendorModuleSetup;

use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;

class InstallData implements InstallDataInterface

    private $eavSetupFactory;

     * Constructor
     * @param MagentoEavSetupEavSetupFactory $eavSetupFactory
    public function __construct(EavSetupFactory $eavSetupFactory)
        $this->eavSetupFactory = $eavSetupFactory;

     * {@inheritdoc}
    public function install(
        ModuleDataSetupInterface $setup,
        ModuleContextInterface $context
    ) {
        $eavSetup = $this->eavSetupFactory->create(('setup' => $setup));

                'type' => 'varchar',
                'label' => 'Navigation Thumbail Image',
                'input' => 'image',
                'sort_order' => 10,
                'source' => '',
                'global' => 0,
                'visible' => true,
                'required' => false,
                'user_defined' => false,
                'default' => null,
                'group' => 'General Information',
                'backend' => 'MagentoCatalogModelCategoryAttributeBackendImage'

  1. To show custom image attribute on admin category form


<?xml version="1.0" ?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="general" sortOrder="10">
        <field name="custom_image" sortOrder="10" formElement="imageUploader">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">category</item>
                <label translate="true">Custom Image</label>
                            <param xsi:type="url" name="url" path="catalog/category_image/upload"/>
                        <openDialogTitle>Media Gallery</openDialogTitle>
                        <allowedExtensions>jpg jpeg gif png</allowedExtensions>

That’s it. run upgrade php bin/magento setup:upgrade and clear cache php bin/magento cache:flush. The newly added category image attrribute would show as shown below.

enter image description here


Will category discounts double if items are in multiple categories?

If I set up a catalogue discount for 40% off the women’s category and 40% off the sale category, will items that live in both the women’s and the sale category end up at 80% off? What is the best way to do this without having to rearrange all our items?

custom taxonomy – Displaying all posts by category and showing content on click

I am building a WordPress site for a composer who has written over 200 pieces of music. Each is a custom post (work), organised by a hierarchical custom taxonomy/category (type – being orchestral, vocal, etc).

I need to build a catalogue page in which all works are displayed in lists by type:

Orchestral Works:

Vocal Works:


The user can add categories to the list, so I can’t simply write a query for each category. The catalogue page needs to check the list dynamically.

So far so good. This can be achieved – and sorted the way I need – like this:

    $cat_terms = get_terms(
            'hide_empty' => true,
            'orderby' => 'name',
            'order' => 'ASC',
            'number' => 9999 
    if( $cat_terms ) :
    foreach( $cat_terms as $term ) :
    echo '<h5>'. $term->name .'</h5>';

<?php $args = array(
    'post_type' => 'work',
    'posts_per_page' => 9999, // Assuming no-one is this prolific
    'post_status' => 'publish',
    'tax_query' => array(
            'taxonomy' => 'type',
            'field' => 'slug',
            'terms' => $term->slug,
    'ignore_sticky_posts' => true,
    'meta_key' => 'date',
    'orderby' => 'meta_value',
    'order' => 'DESC'
    $_works = new WP_Query( $args );
        if( $_works->have_posts() ) :
            echo '<table>';
                while( $_works->have_posts() ) : $_works->the_post(); ?>
                        <td><?php the_field('date'); ?><td><?php the_title(); ?></td>
                <?php endwhile;
            echo '</table>';

I then need to be able to display the content of the CPT (a small amount of data in a few custom fields) in another div in the same page (and not link out to a single-work.php template as would be more usual). This would be like a tabbed content effect – one posts’ content displayed at a time, chosen from the category-based list on the page.

enter image description here

I could create this second part by loading everything and toggling visibility via jQuery but that would mean loading 200+ posts with the page and making them invisible, which strikes me as a terrible idea.

Is it possible to fetch/load the content of the selected post dynamically on click, so only the posts required are queried beyond the initial list? How would this be handled, and where would I begin with it?

ct.category theory – Functor category with only isomorphisms in the Gamma space construction

I’m looking at the Gamma space construction in the paper “Gamma spaces and information” by Matilde Marcolli. For a pointed set $X$ one takes the category $P(X)$ of pointed subsets of $X$ and inclusions, a category $mathcal{C}$ with coproducts and a zero, and then looks at the functor category $Sigma_mathcal{C}(X)$ of summing functors $P(X) rightarrow mathcal{C}$. Summing functors send base point of $X$ to zero of $mathcal{C}$, $Phi_X(ast) = 0$, and for $A cap B = {ast}$, $Phi_X(A cup B) = Phi_X(A) oplus Phi_X(B)$, where $oplus$ denotes the coproduct of $mathcal{C}$. The Gamma space construction for $X$ is finalized by taking the nerve of the category of summing functors, $mathcal{N}Sigma_mathcal{C}(X)$.

It is then stated that the morphisms in $Sigma_mathcal{C}(X)$ are the natural isomorphisms. My question is why this is done? Is there some, possibly basic reason I’m missing, to take only the isomorphisms as morphisms of your category. In this construction or in general. Looking at the answer Category with one isomorphism class, is this somehow related to enforce skeletality on the category and then the nerve above becomes nicer?