[wp-trac] [WordPress Trac] #2861: Added filter to process custom

WordPress Trac wp-trac at lists.automattic.com
Sun Jun 25 13:55:36 GMT 2006


#2861: Added filter to process custom tag fields
-------------------------+--------------------------------------------------
 Reporter:  DevaSatyam   |       Owner:  anonymous
     Type:  enhancement  |      Status:  new      
 Priority:  normal       |   Milestone:           
Component:  General      |     Version:           
 Severity:  minor        |    Keywords:           
-------------------------+--------------------------------------------------
 I added a picture gallery to WP and wanted to be able to add to my posts a
 reference to the related picture category.  I figured that adding custom
 tags to the post would be the best way to do it.  Then, I needed them
 processed so I added a filter to the the_meta() function.

 I followed the instructions on how to add a patch, but right now, I don't
 see a way to attach the patch, so here it goes in source form:


 {{{
 Index: wp-includes/post-template.php
 ===================================================================
 --- wp-includes/post-template.php       (revision 3923)
 +++ wp-includes/post-template.php       (working copy)
 @@ -212,7 +212,7 @@
                                 continue;
                         $values = array_map('trim',
 get_post_custom_values($key));
                         $value = implode($values,', ');
 -                       echo "<li><span class='post-meta-key'>$key:</span>
 $value</li>\n";
 +                       echo apply_filters('custom_tags',"<li><span class
 ='post-meta-key'>$key:</span> $value</li>\n",$key,$value);
                 }
                 echo "</ul>\n";
         }

 }}}

 As for how it is used, this is the code that I added to my picture
 gallery.  I used Photopress as the basis for my gallery, but I modified it
 so the code as shown is unusable with the original distribution, it is
 just an example.


 {{{
 add_filter('custom_tags','photopress_custom_tags_process',10,3);

 function photopress_custom_tags_process($custom_tag,$key,$value) {
         // sample: <li><span class='post-meta-key'>$key:</span>
 $value</li>\n
         switch($key) {
                 case 'photopress_cat':
                         return '<li><a href="?pp_album=main&amp;pp_cat=' .
 intval($value) . '">' . __('Photos','photopress') . '</a></li>';
                 case 'photopress_image':
                         $args=explode(',',$value);
                         return '<li><a href="?pp_album=main&amp;pp_cat=' .
 intval($args[0]) . '&amp;pp_image=' . intval($args[1]). '">' .
 __('Photo','photopress') . '</a></li>';
                 default:
                         return $custom_tag;
         }
 }
 }}}


 Satyam

-- 
Ticket URL: <http://trac.wordpress.org/ticket/2861>
WordPress Trac <http://wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list