WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
events list shortcode html output problem (6 posts)

  1. raskull
    Member
    Posted 2 years ago #

    This shortcode:
    <ul>[events_list category="5"]<li>#_EVENTDATES: #_EVENTLINK</li>[/events_list]</ul>
    generates this html:

    <ul>
    	<li>31/01/2012: <a href="#">An Event</a></li>
    	<p>
    	<li>12/02/2012: <a href="#">Another Event</a></li>
    	<p>
    </ul>

    Note the extraneous <p> tags being added. Please advise...

    http://wordpress.org/extend/plugins/events-manager/

  2. raskull
    Member
    Posted 2 years ago #

    And when I (my clients) switch to the visual editor, the above shortcode generates this html:

    <ul>
    <ul></p>
    <li>31/01/2012: <a href="#">An Event</a></li>
    </ul>
    </ul>
    <p></p>
    <li>12/02/2012: <a href="#">Another Event</a></li>
    </ul>
    </ul>
    <p></p>
  3. agelonwl
    Member
    Posted 2 years ago #

  4. raskull
    Member
    Posted 2 years ago #

    Yeah, I can get rid of the p tags but I still end up with this when switching to the visual editor:

    <ul>
    <ul>
    <li>31/01/2012: <a href="#">An Event</a></li>
    </ul>
    </ul>
    <li>12/02/2012: <a href="#">Another Event</a></li>
    </ul>
    </ul>

    The only way around that is to not use the visual editor, but I can't very well tell my clients that. Will try rolling my own shortcode....

  5. raskull
    Member
    Posted 2 years ago #

    So, I am trying to create an events list shortcode that the visual editor can't mess with (see above). This means that I need all the html to build within the shortcode.

    Can you help me with the syntax?

    This is as far as I got (copying your shortcode code):

    function em_my_get_events_list_shortcode($atts, $format='') {
    	$atts = (array) $atts;
    	$atts['format'] = ($format != '' || empty($atts['format'])) ? $format : $atts['format'];
    	$atts['format'] = html_entity_decode($atts['format']); //shorcode doesn't accept html
    	$atts['page'] = ( !empty($atts['page']) && is_numeric($atts['page']) )? $atts['page'] : 1;
    	$atts['page'] = ( !empty($_GET['page']) && is_numeric($_GET['page']) )? $_GET['page'] : $atts['page'];
    	return '<ul class="myeventlist">' . EM_Events::output( $atts ) . '</ul>';
    }
    add_shortcode ( 'my_events_list', 'em_my_get_events_list_shortcode' );

    The shortcode should look like this:
    [my_events_list category="5"]
    instead of this:
    <ul class="myeventlist">[my_events_list category="5"]<li>#_EVENTDATES: #_EVENTLINK</li>[/events_list]</ul>

    and the output should look like this:

    <ul class="myeventlist">
    	<li>31/01/2012: <a href="#">An Event</a></li>
    	<li>12/02/2012: <a href="#">Another Event</a></li>
    </ul>
  6. raskull
    Member
    Posted 1 year ago #

    function em_my_get_events_list_shortcode($atts) {
    	$atts = (array) $atts;
    	$atts['format'] = '<li>#_EVENTDATES: #_EVENTLINK</li>';
    	return '<ul class="myeventlist">' . EM_Events::output( $atts ) . '</ul>';
    }
    add_shortcode ( 'my_events_list', 'em_my_get_events_list_shortcode' );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic