Advanced Venue Queries and Latest Venues?

WordPress Event Management, Calendars & Registration Forums General Question Advanced Venue Queries and Latest Venues?

This topic contains 8 replies, has 2 voices, and was last updated by  Stephen Harris 10 years, 10 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #6279

    Hi Stephen,

    Thanks for your help the other day regarding the map size and customisable icons.

    Further to your recommendation of purchasing the pro version for the advanced querying techniques, if I explain what I am trying to do you can see if you can help.

    Firstly I would like to have an individual page for each region of the UK i.e. South East, South West, Midlands, North West etc. each of which either lists the venues, or if possible displays them with the thumbnail present and perhaps even a small blurb.

    Secondly would it be possible to have the latest four venues added appearing on the home page, with their images, description and a link to the specific page.

    It might help if you see the four ‘Venue’ spaces on the home page at http://www.s2fvenues.co.uk

    Cheers,

    Kyle

    Kyle Bailey
    #6280

    Hi Kyle,

    There are a couple ways of doing this – you could create a page template which expects a custom query variable to identify which region you want to display, and then perform the appropriate queries (see below).

    … But if you only have four regions, and you may wish to write a blurb for each region then you could create four pages and in each use a shortcode such as:

    [s2fvenues region="North West"]
    

    (for the North West page). I’ll leave the details of the implementation to you and detail the bit relevant to querying/displaying venues – which won’t change much depending on how whether you go down the page-shortcode or page-template route.

    (see also http://wp-event-organiser.com/blog/tutorial/creating-your-own-shortcodes/ )

    The following assumes you are storing the region with venue meta key ‘region’:

    add_shortcode( 's2fvenues', 's2fvenues_region_shortcode_handler' );
    function s2fvenues_region_shortcode_handler( $atts ){
        $atts = shortcode_atts( array(
            'region' => 'North West',
        ), $atts );
    
        //Get venues with 'region' set to  $atts['region'].
        $venue_query = array( array(
            'key' => 'region',
            'value' => $atts['region'],
            'compare' => '='
        ));
        $venues = eo_get_venues( array( 'meta_query' => $venue_query ) );
    
        //Display venues - you can change the mark-up
        $html = '';
    
        foreach( $venues as $venue ){
    
            $venue_id = (int) $venue->term_id;
            $html .= '<div class="s2ff-venue">';
    
            //Venue name
            $html .= '<h2>' . esc_html( eo_get_venue_name( $venue_id ) ) . '</h2>';
    
            //Venue description
            $html .= '<div class="s2ff-venue-descrption">' . eo_get_venue_description( $venue_id ) . '</div>';
    
            //Venue description
            $html .= eo_get_venue_thumbnail( $venue_id, 'post-thumbnail' );
    
            //Venue link
            $html .= '<p><a href="' . esc_url( eo_get_venue_link( $venue_id ) ) . '"> View this venue... </a></p>';
    
            $html .= '</div>';
        } 
        return $html;            
    }
    

    Secondly would it be possible to have the latest four venues added appearing on the home page, with their images, description and a link to the specific page.

    The latest venues should have the highest term ID (this might not be the case if you are using the venue slug across other taxonomies – if that’s the case, there is a work-around) – otherwise:

    $venues = eo_get_venues( array(
            'orderby' => 'id',
            'order' => 'DESC',
            'number' => 4,
    ) );
    
    Stephen Harris
    #6284

    Hi Stephen,

    Thank you for the indepth reply, I have managed to successfully complete the first requirement.

    I am struggling a little more with the second. As I literally only need the first 4 venues without any other queries i.e “location”.

    Also is it possible to limit the number of characters that are generated from the venue description?

    Many thanks,

    Kyle

    Kyle Bailey
    #6285

    Hi Kyle,

    The second query should just return the latest 4 venues – it doesn’t contain a meta query at all…

    Regarding trimming the description, you might want to use wp_trim_words(): http://queryposts.com/function/wp_trim_words/

    Stephen Harris
    #6286

    Thanks for the reply. I’m struggling with the, I must admit it isn’t my forté! How far off am I with this:

    add_shortcode( 's2fvenues_latest', 's2fvenues_latest__region_shortcode_handler' );
    

    function s2fvenues_latest_region_shortcode_handler( $atts ){
    $atts = shortcode_atts( array(
    ‘region’ => ‘North West’,
    ), $atts );

    //Get venues with 'region' set to  $atts['region'].
    

    $venues = eo_get_venues( array(
    ‘orderby’ => ‘id’,
    ‘order’ => ‘DESC’,
    ‘number’ => 4,
    ) );

    //Display venues - you can change the mark-up
    $html = '';
    
    foreach( $venues as $venue ){
    
        $venue_id = (int) $venue->term_id;
        $html .= '<div class="s2ff-venue">';
    
        //Venue name
        $html .= '<h2>' . esc_html( eo_get_venue_name( $venue_id ) ) . '</h2>';
    
        //Venue description
        $html .= '<div class="s2ff-venue-descrption">' . eo_get_venue_description( $venue_id ) . '</div>';
    
        //Venue description
        $html .= eo_get_venue_thumbnail( $venue_id, 'post-thumbnail' );
    
        //Venue link
        $html .= '

    View this venue...

    '; $html .= '</div>'; } return $html;
    • This reply was modified 10 years, 10 months ago by  Kyle Bailey.
    Kyle Bailey
    #6292

    Hi Stephen,

    Quick update on where I am at:

    I have managed to list the four latest venue, but am still struggling with the wp_trim_words() as I get errors when I add the code to my Utility Plugin?

    Also, regarding the venue template, from mobile devices the widget sidebar display underneath the main content rather than to the side – any idea how to change this?

    Lastly, the venue drop-down widget only displays venues that have events associated with them. The site I am making has no events, is there a way to make all venues display regardless?

    Many thanks,

    Kyle

    Kyle Bailey
    #6293

    Hi Kyle,

    What error do you get when using wp_trim_words()?

    R.e. the venue template – that’s normal behaviour for responsive websites. In any case, if that’s not what you’re theme is doing you can edit the template ( taxonomy-event-venue.php) so that’s its layout matches that of a standard theme template (comparingtaxonomy-event-venue.php with your theme’s category.php – if it exists – will probably be helpful).

    Regarding the venue dropdown, try the following:

    add_filter( 'eventorganiser_widget_event_venues_dropdown_args', 's2fvenues_venue_dropdown_args' );
    function s2fvenues_venue_dropdown_args( $args ){
      $args['hide_empty'] = 0;
      return $args;
    }
    

    In response to your previous post – you might want to link to a GitHub Gist or pastebin since it seems to have swallowed some of the code. But it seems to follow my previous post fairly closely.

    Stephen Harris
    #6294

    Cheers for the quick, out-of-hours reply!

    I don’t actually receive and error message so to speak, but the site fails to load completely?

    That code has worked perfectly, all venues are showing up now!

    Ok, I’ll continue to look into the templates – just wanted to see if you had a quick work-round.

    Thanks again,

    Kyle

    Kyle Bailey
    #6295

    Could you put the site into debug mode? How are you using the function, example usage is: `echo wp_trim_words( $text_to_trim, 35 ); ` Obviously, you’ll want to replace `$text_to_trim` with the venue description.

    • This reply was modified 10 years, 10 months ago by  Stephen Harris.
    Stephen Harris
Viewing 9 posts - 1 through 9 (of 9 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.