glevine 0 Report post Posted April 19, 2011 I recently saw a reply by Adam Munns that showed the following solution to modifying the way meta data is displayed in the metabar using the Base functions.php file... add_filter('pagelines_post_metabar', 'your_function'); function your_function($metabar){ $metabar = sprintf( '<span class="sword">%s</span> [post_date] ', __('On','pagelines') ); return $metabar; } Expanding on this, I'd like to only modify the way the metabar is displayed when in "clips" format. The function in PlatformPro's library.templates.php file is the following: add_filter('pagelines_post_metabar', 'do_shortcode', 20); function pagelines_get_post_metabar( $format = '' ) { $metabar = ''; if ( is_page() ) return; // don't do post-info on pages if( $format == 'clip'){ $metabar .= sprintf( '<span class="sword">%s</span> [post_date] ', __('On','pagelines') ); $metabar .= sprintf( '<span class="sword">%s</span> [post_author_posts_link] ', __('By','pagelines') ); } else { if(pagelines_option('byline_author')){ $metabar .= sprintf( '<span class="sword">%s</span> [post_author_posts_link] ', __('By','pagelines') ); } if(pagelines_option('byline_date')){ $metabar .= sprintf( '<span class="sword">%s</span> [post_date] ', __('On','pagelines') ); } if(pagelines_option('byline_comments')){ $metabar .= '· [post_comments] '; } if(pagelines_option('byline_categories')){ $metabar .= sprintf( '· <span class="sword">%s</span> [post_categories]', __('In','pagelines') ); } } $metabar .= ' [post_edit]'; printf( '<div class="metabar">%s</div>', apply_filters('pagelines_post_metabar', $metabar) ); }[/code] How can I make sure the "format" parameter is passed correctly to the filter I've added in my Base functions.php file? Thanks! Share this post Link to post Share on other sites
cmunns 16 Report post Posted April 19, 2011 Use the same conditionals as in the original function e.g. ` if( $format == 'clip'){ $metabar .= sprintf( '%s [post_date] ', __('On','pagelines') ); } ` Share this post Link to post Share on other sites
glevine 0 Report post Posted April 20, 2011 Hmmm... I did that, but it doesn't come out the way I want it. Here's what I added to the Base functions.php file. add_filter('pagelines_post_metabar', 'base_get_post_metabar'); function base_get_post_metabar( $format = '' ) { $metabar = ''; if ( is_page() ) return; // don't do post-info on pages if( $format == 'clip'){ $metabar .= sprintf( '<span class="sword">%s</span> [post_date] ', __('On','pagelines') ); } else { if(pagelines_option('byline_author')){ $metabar .= sprintf( '<span class="sword">%s</span> [post_author_posts_link] ', __('By','pagelines') ); } if(pagelines_option('byline_date')){ $metabar .= sprintf( '<span class="sword">%s</span> [post_date] ', __('On','pagelines') ); } if(pagelines_option('byline_comments')){ $metabar .= '· [post_comments] '; } if(pagelines_option('byline_categories')){ $metabar .= sprintf( '· <span class="sword">%s</span> [post_categories]', __('In','pagelines') ); } } $metabar .= ' [post_edit]'; return $metabar; } The output I'm getting on the homepage (magazine format) is On March 19, 2011 ?· Leave a Comment ?· In News. If the format is "clip", then it should be just On March 19, 2011. So I'm not sure why the format isn't being recognized correctly. Maybe you have an idea of where I'm going wrong? Share this post Link to post Share on other sites
cmunns 16 Report post Posted April 20, 2011 Hmm maybe it won't work because the $format variable isn't reachable outside of the function. Let me know see if I can more info. Share this post Link to post Share on other sites
glevine 0 Report post Posted April 25, 2011 Thanks for looking into this, Adam. Any luck finding a solution? Share this post Link to post Share on other sites
cmunns 16 Report post Posted April 26, 2011 Andrew is going to add to the filter for v 1.4 Share this post Link to post Share on other sites
matt85 1 Report post Posted June 13, 2011 Hi, any progess on this? I think the problem is that the add_filter command in wordpress does not allow to pass variables to substituted functions. Take a look at the parent theme: the function pagelines_post_metabar is called in template.postloop.php (line 142) and 'clip' is passed to the function. You can't pass this by sustituting with the add_filter command. The following works for me: Copy the pagelines_post_metabar function to your functions.php in your base theme and rename the function (dont' forget the printf -line at the end!). Don't do the add_filter('pagelines_post_metabar', 'your_function') thing, you won't need it with this approach. Then copy the library.templates.php to your child-theme folder, too. In the copied library.templates.php go to line 142 and change the pagelines_post_metabar('clip'); to your_renamed_function('clip'); That should do. Drawback: when updating the theme you have to manually update the library.templates.php and reapply the changes. If you don't want to mess up in library.templates.php another solution would be using conditional tags (http://codex.wordpress.org/Conditional_Tags) like is_home instead of if( $format == 'clip'). With that you should take Adam Munns approach of course. Share this post Link to post Share on other sites
catrina 103 Report post Posted June 14, 2011 If you want, you can also wait for the update that will include the filter. Please read the docs before posting. Please do not private message me unless I ask you to. Designer | Catrina Dulay Founder | Catrina and Mouse Share this post Link to post Share on other sites