Title: Problems with the [pass] shortcode
Last modified: August 21, 2016

---

# Problems with the [pass] shortcode

 *  Resolved [Mpampirina](https://wordpress.org/support/users/mpampirina/)
 * (@mpampirina)
 * [12 years ago](https://wordpress.org/support/topic/problems-with-the-pass-shortcode/)
 * Hello! I wonder if you could help me a bit with the [pass] shortcode.
    I’m building
   a website for an educational institute. For the courses, I use regular pages 
   with custom fields (created by ‘Advanced Custom Fields’). For the faculty, I’m
   using another plugin that creates a custom post type.
 * On each course page, I’d like to display a few info from the custom fields, and
   the faculty member teaching it (associated through ACF).
 * So this is what i’m doing so far:
 *     ```
       <p><h6>Course code</h6>
       [content field="icsd-code"]</p>
   
       <p><h6>ECTS</h6>
       [content field="icsd-ects"]</p>
   
       <p><h6>Field</h6>
       [content field="icsd-fields"]</p>
   
       <p><h6>Teacher</h6>
       [content field="icsd-teaching"]
       // here it displays just a number - the custom post id of the associated faculty member
   
       [pass field="icsd-teaching"]
               [content id="{FIELD}" type="faculty"  field="title"]
               [content id="{FIELD}" type="faculty" field="image"]
       [/pass]
   
       </p>
       ```
   
 * The custom fields from the course page are displayed just fine. But when I pass
   the ID to my custom post type, something goes really wrong… any idea what that
   might be?
 * [https://wordpress.org/plugins/custom-content-shortcode/](https://wordpress.org/plugins/custom-content-shortcode/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [Mpampirina](https://wordpress.org/support/users/mpampirina/)
 * (@mpampirina)
 * [12 years ago](https://wordpress.org/support/topic/problems-with-the-pass-shortcode/#post-4948507)
 * Something I just thought of and it might need to be taken into consideration…
   The ‘icsd-teaching’ field may contain either an array of post objects or an array
   of page link, because one course can be assigned to more than one teachers.
 * In both cases, the [content field=”icsd-teaching”] displays one or more numbers-
   ids (depending on the assigned teachers), while the fields inside [pass] display
   nothing…
 * In this light, when I try:
 *     ```
       [pass field="icsd-teaching"]
           [loop id="{FIELD}" type="faculty"]
               [content field="title"]
               [content field="image"]
           [/loop]
       [/pass]
       ```
   
 * it displays each and every one of the faculty members, no matter if they are 
   assigned to this course…
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [12 years ago](https://wordpress.org/support/topic/problems-with-the-pass-shortcode/#post-4948690)
 * Hello,
 * I apologize for the late reply! It looks like the issue is that the [pass] shortcode
   can’t process a field with an array as value.
 * OK, I’m going to improve the [pass] shortcode so that your second example works
   as expected, to pass the array of post IDs to the loop.
 * Just to confirm, you said `[content field="icsd-teaching"]` displays a comma-
   separated list of post IDs? In that case, it should be straight-forward to implement.
   I’ll let you know as soon as it’s ready.
 *  Thread Starter [Mpampirina](https://wordpress.org/support/users/mpampirina/)
 * (@mpampirina)
 * [12 years ago](https://wordpress.org/support/topic/problems-with-the-pass-shortcode/#post-4948691)
 * Yes, I just tested it again, and I can confirm that `[content field="icsd-teaching"]`
   returns a comma-separated list of post IDs.
 * I actually found my way around, by adding the enhanced text plugin which allowed
   me to inject some php straight into my widget. But adding support for arrays 
   would be a good idea 🙂
 * And just for the sake of clarity and completion, here is what my widget looks
   like at the moment (it’s ugly, I know, but it works):
 *     ```
       <h4>Πληροφορίες</h4>
       <h5>Κωδικός</h5>
       [content field="icsd-code"]
   
       <h5>Κατεύθυνση</h5>
       [content field="icsd-area"]
   
       <h5>ECTS</h5>
       [content field="icsd-ects"]
   
       [if flag="icsd-eclass"]
               <h5>E-class</h5>
               [flag]
       [/if]
   
       <?php
       $post_objects = get_field('icsd-teaching');
       if( $post_objects ): ?>
           <h5>Διδάσκοντες</h5>
           <?php foreach( $post_objects as $post_object): ?>
               <div class="course-teacher">
                   <ul>
                   <li><?php $the_thumb = get_the_post_thumbnail($post_object->ID, 'thumbnail');
       if ( $the_thumb == "") {
               $dwidth = 150;
       	$the_thumb .= "<img src='".plugins_url( '../faculty-members/img/default.png', __FILE__ )."' width='".$dwidth."'/>";
   
       			}
       echo $the_thumb;
       ?>
   
       </li>
                   <li><?php echo get_the_title($post_object->ID); ?></li>
   
       <li><?php
       $fmemail = get_post_meta($post_object->ID, 'fmemail', true);
       echo eeb_email($fmemail, '<span class="icon, icon-envelope"> E-mail</span>'); ?>
       </li>
                   </ul>
   
               </div>
           <?php endforeach; ?>
   
       <?php endif;
   
       ?>
       ```
   
 * By the way I think I’m using incorrectly the [if] [flag]. But this may belong
   to another topic.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [12 years ago](https://wordpress.org/support/topic/problems-with-the-pass-shortcode/#post-4948693)
 * I just updated the plugin with an improved [pass] shortcode, which should handle
   the field value correctly when it’s an array, passing a comma-separated list.
 * So, the code you wrote earlier should work now:
 *     ```
       [pass field="icsd-teaching"]
           [loop id="{FIELD}" type="faculty"]
               [content field="title"]
               [content field="image"]
           [/loop]
       [/pass]
       ```
   
 * You can also test the field value by doing this:
 *     ```
       [pass field="icsd-teaching"]
           {FIELD}
       [/pass]
       ```
   
 * Yes, I see the widget is looking wild with a combination of shortcodes and PHP.
   🙂 This is one reason why I wrote this plugin, to simplify the code necessary
   to do such queries. So, I’d be glad if you could make it work with only shortcodes.
 * It looks like you’re using the if/flag as intended: if the field _icsd-eclass_
   is not empty, it displays the title and value.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Problems with the [pass] shortcode’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

## Tags

 * [pass](https://wordpress.org/support/topic-tag/pass/)
 * [recursive](https://wordpress.org/support/topic-tag/recursive/)

 * 4 replies
 * 2 participants
 * Last reply from: [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/problems-with-the-pass-shortcode/#post-4948693)
 * Status: resolved