• Resolved n4pwpsupport

    (@n4pwpsupport)


    Hi there.

    On the Single Event page I’m trying to get the name of one of the several categories the Event is assigned to. How to get it and use in the single-event.php?

    For example:

    Event_ID = 1234
    It assigned to the categories ‘New‘, ‘Start‘, ‘Test‘, ‘West‘.

    The
    <?php the_category(' &bull; '); ?>

    returns all these categories as the list.

    But the

    $category = get_the_category();
    echo $category[0]->cat_name;

    returns nothing. The array is empty.

    How to get the name ‘Test’ for example?

    Many thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    you can try something like $EM_Event->output('#_CATEGORYNAME')

    Thread Starter n4pwpsupport

    (@n4pwpsupport)

    Angelo, thanks for the info.

    But how to get the first/second/third category name/id?

    In vanila WP the

    $category = get_the_category();
    echo $category[0]->cat_name;

    returns the name of the category in brackets (0/1/2/3…).

    Why it doesn’t work in EM? the_category () works and get_the_category() – doesn’t.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    I think the best snippet you can check to loop events categories is under events-manager/templates/placeholders/categories.php

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to get the Category Name for Event in the template’ is closed to new replies.