WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: RSVPmaker] a way to pull specific Event Types using custom fields? (2 posts)

  1. AardvarkGirl
    Member
    Posted 2 years ago #

    I've wrapped my mind around using custom fields and now I would like to use custom fields to pull a list of events from a specific event type created by this plugin.

    I'm using the RSVPmaker calendar/rsvp plugin. In this plugin I can create 'Event Types'. I assume this works like post categories - example;

    Intro To Ponies Classes with a slug of 'intro-to-ponies-classes'

    Then, like posts, as you create events you can assign them to your 'Event Types'. However, it does not create a way to view a list of events by the types (like categories), and I can not find an ID (like a category ID).

    What would be the correct WordPress-terminology for this? A custom post type? A taxonomy? Anyhow.

    You can also tag events with the standard post tags, but an event post tagged 'cat' won't show up in a list of posts tagged 'cat'. Example:

    An event entry: http://www.startingpointstables.com/rsvpmaker/level-1-2-combo-class-430/ notice the tag 'pony school classes'. Yet, once you click on the tag link, you won't see that event.

    Since I couldn't see a way to find an ID number for the plugins 'Event Types' I figured I could use the tags, but that won't work.

    Anyone have any better ideas?

  2. AardvarkGirl
    Member
    Posted 2 years ago #

    Stayed up late and got up early for this one. :)

    I wish I could reword the post title - has little to do with custom fields at this point. I just need to query a plugins 'custom post type'. (I think?!?)

    So, I think I have my terminology correct for 'custom post types', and if so, then I went and looked at the plugin on the back end and found this in the URL for the 'event types';

    &taxonomy=rsvpmaker-type&tag_ID=<strong>6</strong>&post_type=rsvpmaker

    Playing detective I looked at a native WordPress posts type (picked one) and noticed the tag IDs...

    taxonomy=post_tag&tag_ID=<strong>42</strong>&post_type=post

    So thinking "Hmm, I can already pull in a list of posts by tag ID (using 42), so I'll use the ID of 6 and see what I get" using this...

    <?php
    //get all terms (e.g. categories or post tags), then display all posts in each term
    $taxonomy = 'post_tag';//  e.g. post_tag, category
    $param_type = 'tag__in'; //  e.g. tag__in, category__in
    $term_args=array(
      'include' => '42',
    );
    $terms = get_terms($taxonomy,$term_args);
    if ($terms) {
      foreach( $terms as $term ) {
        $args=array(
          "$param_type" => array($term->term_id),
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => -1,
          'caller_get_posts'=> 1
          );
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo 'List of Posts in '.$taxonomy .' '.$term->name;
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
          endwhile;
        }
      }
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    It worked for ID 42, but not for ID 6 (this one being the plugin's post).

    Then I went in and tried to query for a particular post number using this

    <?php
    // retrieve one post with an ID of X
    query_posts( 'p=803' );
    
    // set $more to 0 in order to only get the first part of the post
    global $more;
    $more = 0;
    
    // the Loop
    while (have_posts()) : the_post();
    	the_content( 'Read the full post ยป' );
    endwhile;
    ?>

    worked for a regular post ID number (getting the post number from the admin url, post=803) but did not work for this plugins post ID number (getting the post number from the admin url, post=1016).

Topic Closed

This topic has been closed to new replies.

About this Topic