List events title (with link) by categories

I need to list a title events with link oder by categories. And i need to a widgets on single envent page, them try to create a sortcode on functions.php on my theme, but no work.

This is de code:

add_shortcode('listados', 'shortcode_listados');
function shortcode_listados () {
global $booking, $wpdb, $wp_query, $post;
$events = array ($args);
$event = ($post instanceof Eab_EventModel) ? $post : new Eab_EventModel($post);
$listado ='';
$listado .= '<div id="primary">';
$listado .= '<div id="content" role="main">';
$listado .= '<div id="wpmudevevents-wrapper">';
if ( !have_posts() ) {
$listado .='<h3>'. Eab_Template::get_event_link($post) .'</h3>';
$listado .='<p>No post <?php $event_ptype = get_post_type_object(incsub_event); $event_ptype->labels->not_found; ?></p>';
$listado .='<div class="wpmudevevents-list">SI pOST';
while ( have_posts() ) : the_post();
$listado .='<div class="event ';
$listado .= Eab_Template::get_status_class($post);
$listado .='">';
$listado .='<div class="wpmudevevents-header">';
$listado .='<h3>'. echo Eab_Template::get_event_link($post); '.</h3>';
$listado .='</div>';


$listado .='</div>';

$listado .='</div></div></div>';
return $listado;

Thanks in advance:relaxed:

  • Sajid
    • DEV MAN’s Sidekick

    Hi @mira360,

    Hope you are doing good today :slight_smile:

    To list events title in a specific category and output them via a shortcode you can use Display Posts Shortcode plugin.

    I know you don’t want to list posts but events. Since events are custom post types of WordPress and this plugin have support to list posts/custom posts of category/taxonomy so we can use this plugin instead of reinventing the wheel.

    This plugin also have detailed documentation + dozens of filters/actions to modify the layout of posts/custom posts.

    So install this plugin and use following shortcode to list titles with links of events in a specific events category. Make sure you have replaced replace_with_category_slug with your event’s category slug. You can also use multiple categories separated by comas.

    [display-posts post_type="incsub_event" taxonomy="incsub_event" tax_term="replace_with_category_slug" tax_operator="IN"]

    For further customization and details of other paramters of this shortcode see this official documentation on github.

    For future reference please don’t post multiple replies in a thread. Because our system feeds us threads from oldest to newest. So whenever you post a new reply it pushes you towards the bottom of queue. Its not an excuse but explanation of how our system works. Always post one consolidated reply and wait for staff to reply.

    Hope that helps! Feel free to post a reply if you need further assistance :slight_smile:

    Cheers, Sajid

  • mira360
    • Design Lord, Child of Thor

    Thanks Sajid Sajid,

    I wanted to make my own shortcode to have full control over what to list. This solution is similar to the desired new, but not exact. Let me explain to me, thank you:

    We needed to print on-screen exactly similar to the following THML:

    Category title with link with anchor type <a name = ….

    Take Sub-category and list events only title with link to the next event (not all).

    Next Sub-category, (same and reapet list upcoming events.)

    Necsitabamos generate dynamically similar to this html:

    <Div class = "widget">
    <H3> CRAFTS COURSES </ h3>
    <Div id = "current"> natural course Candles and Fantasy </ div>
    <Div id = "current"> Course felted wool </ div>
    <a name="COURSES-AND-ACTIVITIES"> </a> <!-The name to put it before so you look better on screen, when be chosen-->
    <Div id = "current"> Custom Courses </ div>
    </ Div>
    <Div class = "widget">
    <Div id = "current"> Recognition Course Mushrooms </ div>
    <Div id = "current"> Recognition Course Medicinal Plants </ div>

    I understand that with this plugin I can not do it and the absence of documentation on how to do the loop, I need your help.

    Thank you

  • mira360
    • Design Lord, Child of Thor

    a week with no solution? Consider this acceptable in what is understood to be a premium support?

    I think it’s very simple what I’m asking, and for the second time leave me the right answers. Then they complain that if I open a new ticket, but if not constetan me can anyone tell me what to do?

    Surely if the plugin dispusiera proper documentation on their variables and functions, it would be easier to make custom templates, as you yourselves say advertised on the characteristics of the plugin.

    Also if the default presentation templates out Minimally practical, nor would necesari much customization.

    But back to the case, I repeat … a week with no solution? They consider this acceptable in what is understood to be a premium support?

  • Ash
    • WordPress Hacker

    Hello @mira360

    I hope you are doing good.

    I am sorry for the delay in your thread. I am still not 100% clear about your requirement, but let me give you an idea that should help you. Here I wrote a shrotcode to print all events sorted by category. Please try the following code:

    add_shortcode( 'listados', 'listados_cb' );
    function listados_cb() {

    $html = '';
    $terms = get_terms( array( 'taxonomy' => 'eab_events_category' ) );

    foreach( $terms as $term ) {
    $html .= '<h3>' . $term->name . '</h3>';
    $posts = get_posts(array(
    'post_type' => 'incsub_event',
    'numberposts' => -1,
    'tax_query' => array(
    'taxonomy' => 'eab_events_category',
    'field' => 'id',
    'terms' => $term->term_id

    foreach( $posts as $post ) {
    $html .= '<div class="ev_list">';
    $html .= '<a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a>';
    $html .= '</div>';


    return $html;

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.



  • Panos
    • SLS

    Hello mira360,

    I hope you are doing well today!

    Sincere apologies for such a late response.

    I am not sure what exactly you need the shortcode to do, but here is one which displays the event category title followed by it’s events


    function shortcode_listados(){

    global $post;

    $listado ='';
    $listado .= '<div id="primary">';
    $listado .= '<div id="content" role="main">';
    $listado .= '<div id="wpmudevevents-wrapper">';

    $taxonomies = get_object_taxonomies( (object) array( 'post_type' => 'incsub_event' ) );

    foreach( $taxonomies as $taxonomy ){

    $terms = get_terms( $taxonomy );

    foreach( $terms as $term ){

    $listado .= '<h2>'.$term->name.'</h2>';

    $args = array( 'post_type' => 'incsub_event', 'posts_per_page' => -1, 'taxonomy' => $taxonomy, 'term' => $term->slug );
    $events = get_posts( $args );

    if( empty( $events ) ){
    $listado .='<h3>'. Eab_Template::get_event_link($post) .'</h3>';
    $listado .='<p>No post <?php $event_ptype = get_post_type_object(incsub_event); $event_ptype->labels->not_found; ?></p>';

    $listado .='<div class="wpmudevevents-list">SI pOST';

    foreach ($events as $event) {
    $event = $event instanceof Eab_EventModel ? $event : new Eab_EventModel($event);

    $listado .='<div class="event ';
    $listado .= Eab_Template::get_status_class($post);
    $listado .='">';
    $listado .='<div class="wpmudevevents-header">';
    $listado .='<h3>'. Eab_Template::get_event_link($post); '.</h3>';
    $listado .='</div>';


    $listado .='</div>';



    $listado .='</div></div></div>';

    echo $listado;


    You can test this shortcode in any page by inserting the shortcode

    [wpmu_eventslist order='type']

    In case you want to show the shortcode results in a widget, I suggest trying out this plugin, which allows you to insert any shortcode in a text area, just like in a page.

    Hope this was helpful!

    Please let me know if you need any modification in the code pasted or any further assistance.

    Kind regards,


  • Timothy
    • Chief Pigeon

    Hey there, @mira360.

    I just want to address some stuff here.

    a week with no solution? Consider this acceptable in what is understood to be a premium support?

    No, this is not premium support this is custom and you should be hiring a developer. Whilst I’m happy for my staff to assist with custom stuff, this can take longer and is not prioritised over plugin and theme support and support staff need to consult with developers.

    If you’re not happy to be patient whilst we work through custom stuff, you would need to hire a developer.

    Support is like how to use the plugin, what a feature does, how a setting changes something else, that kind of thing. Here’s a quick guide for you:

    If you need further assistance in customising the function, you can open a job listing here:

    Surely if the plugin dispusiera proper documentation on their variables and functions, it would be easier to make custom templates

    Most of our projects have incode documentation, but you’re expected to be a developer if you wish to make changes. If you’re not a developer, you would need to consider hiring one.

    I’m going to close this ticket up now, thank you for your understanding in this matter.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.