• Resolved lutzcreativegroup

    (@lutzcreativegroup)


    I am trying to make a shortcode that checks if a Time.ly event category is empty. If it is, nothing happens. If it is not, the PHP will put in a <h2>title:

    function editorspicks_func( $atts ) {
    $EditorsPicksCategory = get_category(162);/* 162 = Editor's Picks category under Events > Organize */
    if(!empty($EditorsPicksCategory)) {
        $EditorsPicksCode='<h2>Editor&rsquo;s Picks:</h2>';
    }else{
        $EditorsPicksCode='<h2>Empty:</h2>';
    }
    	return $EditorsPicksCode;
    }
    
    add_shortcode( 'editorspicksevents', 'editorspicks_func' );
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @lutzcreativegroup,

    In regards to customizing code etc.. unfortunately we cannot help with as part of our support. We’ll keep this topic open for a few days for other user to chime in if possible. Thanks for your understanding.

    Thread Starter lutzcreativegroup

    (@lutzcreativegroup)

    You can’t even help me with the hook? I just am not sure how to call that part of the database. Does the traditional “get_category” not work on Time.ly categories? If so, what does? Not asking you write custom code, just let me know how to get a Timely category in PHP.

    I also tried this:

    $EditorsPicksCategory = get_category('post_type=Events&category=164');/* 164 = Editor's Picks category under Events > Organize */

    I am not a developer of the plugin, so I can’t answer those questions. Our dev team is working on bug fixes and developments for our free and paid products in priority sequence. Feature requests are welcome under our Ideas page, also taken in priority sequence, at https://ideas.time.ly.

    Thread Starter lutzcreativegroup

    (@lutzcreativegroup)

    Okay, I will write it there. It’s not really a feature request. I guess I will request some developer documentation.

    Thread Starter lutzcreativegroup

    (@lutzcreativegroup)

    Figured it out.

    // [editorspicksevents]
    function editorspicks_func( $atts ) {
    $EditorsPicksTaxonomy = get_term(164, 'events_categories');//* 164 = Editor's Picks category under Events > Organize */
    $EditorsPicksCategory = $EditorsPicksTaxonomy->count;//Checks the number of Events in this category
    if($EditorsPicksCategory > 0){//If there are events in this category
        $EditorsPicksCode='<div class="EditorsPicksContainer"><h2>Editor&rsquo;s Picks:</h2>';
        $EditorsPicksCode.=do_shortcode('[ai1ec view="agenda" events_limit="5" cat_name="editors-picks"]');
        $EditorsPicksCode.='</div><!-- /EditorsPicksContainer --><h2>All Upcoming Events:</h2>';
    }else{
        $EditorsPicksCode='';
    }
    	return $EditorsPicksCode;
    }
    
    add_shortcode( 'editorspicksevents', 'editorspicks_func' );

    Well done @lutzcreativegroup.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Check if Event Category is Empty’ is closed to new replies.