Here's another conundrum that I'm toying with. There's a routine within the sitewide tags pages plugin which takes a list of custom fields (entered in the admin settings) and then uses these as keys to read a post and output the keys and values in an array. I have not been able to see it working and therefore I am trying to determine why.
Here's the routine within sitewide-tags.php
: http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/
*** line 369 in Version: 0.4.1.1 of sitewide-tags.php ***
$meta_keys = apply_filters( 'sitewide_tags_meta_keys', get_sitewide_tags_option( 'tags_blog_postmeta', array() ) );
$global_meta['DEBUG TEST1'] = $meta_keys;
$global_meta['DEBUG TEST2'] = $post_id;
if( is_array( $meta_keys ) && !empty( $meta_keys ) ) {
foreach( $meta_keys as $key )
$global_meta['DEBUG TEST3'] = 'custom loop';
$global_meta[$key] = get_post_meta( $post->ID, $key, true );
}
unset( $meta_keys );
I have added a small amount of markup to reveal what is happening at each step.
For my test case, post_id #1121, there is one custom field which sits in the wp_9_postmeta
table has one meta_key image
with a corresponding meta_value http://newsite.com/files/2011/05/alfaP.jpg
However the routine returns no value within the function.
Here's what each of the debug tests shows;
DEBUG TEST1:
a:7:{i:0;s:11:"video-embed";i:1;s:9:"image-url";i:2;s:8:"link-url";i:3;s:10:"quote-copy";i:4;s:12:"quote-author";i:5;s:9:"quote-url";i:6;s:9:"audio-url";}
DEBUG TEST2: 1121
DEBUG TEST3: Custom Loop
So the first test (#1) shows that all the custom fields are being returned from the 'get_sitewide_tags_option'
on line 1. The second test (#2) confirms it's looking at the correct post_id and the third test (#3) that it reaches the foreach loop and therefore passes the conditional clause.
EDIT: One further test is to check within the foreach loop and see what value is contained in $key
- what I found is that $key
contains the meta_key
names (image, video-embed...) that should (in theory) be successful when used to retrieve the associated value using 'get_post_meta'
.
I'd love to know why it doesn't - any ideas or suggestions?
$global_meta['image']
give you?