-
AuthorPosts
-
April 29, 2013 at 3:57 pm #22603
I know I should be able to load a modified helper-post-format.php from my child theme folder, but I can’t figure out what I should do in my functions.php. Can anyone point me in the right direction?
Cheers,
Sander
April 30, 2013 at 5:23 am #1163631) Open up wp-contentthemeschoicesincludeshelper-post-format.php – at the very top you’ll see several filter calls like:
add_filter( 'post-format-standard', 'avia_default_title_filter', 10, 1 );
If you want to modify the filter (eg use another, custom filter funtion instead) insert following code into your child theme functions.php:
remove_filter( 'post-format-standard', 'avia_default_title_filter', 10, 1 );
(actually its the same code but you need to replace add_ with remove_).
Now you can call a custom function. So add following code to the functions.php file:
add_filter( 'post-format-standard', 'avia_custom_title_filter', 10, 1 );
and duplicate the avia_default_title_filter() function and rename it to avia_custom_title_filter():
function avia_default_title_filter($current_post)
{
$output = "";
//$output .= "<h2 class='post-title ". avia_offset_class('meta', false). "'>";
$output .= "<h2 class='post-title'>";
$output .= " <a href='".get_permalink()."' rel='bookmark' title='". __('Permanent Link:','avia_framework')." ".$current_post['title']."'>".$current_post['title'];
$output .= " <span class='post-format-icon minor-meta'></span>";
$output .= " </a>";
$output .= "</h2>";
$current_post['title'] = $output;
return $current_post;
}Now you can modify it and overwrite/modify the default content.
May 1, 2013 at 1:22 pm #116364Thanks for this!
It helps, but not completely. I’va added my custom filter, but it seems the normal filter is not removed by
remove_filter( 'post-format-standard', 'avia_default_title_filter', 10, 1 );
This is what I have now:
remove_filter( 'post-format-standard', 'avia_default_title_filter', 10, 1 );
add_filter( 'post-format-standard', 'avia_didm_title_filter', 10, 1 );
function avia_didm_title_filter($current_post)
{
$output = "";
//$output .= "<h2 class='post-title ". avia_offset_class('meta', false). "'>";
$output .= "<h1 class='post-title'>";
$output .= " ".$current_post;
$output .= " <span class='post-format-icon minor-meta'></span>";
$output .= " ";
$output .= "</h1>";
$current_post = $output;
return $current_post;
}
The result is post with two headings, the first one with a class of “h1”, the second with “h2”. And some superfluous code between the two headings…
Ch eers,
Sander
May 1, 2013 at 1:46 pm #116365Ok, it seems like we can’*t remove the filter :/
We’ll take plan B and add some functions_exists() checks to helper-post-format.php – then you should be able to create a modified version of all functions inside your child theme functions.php
May 1, 2013 at 9:26 pm #116366That would be great! Thanks in advance.
Cheers,
Sander
May 2, 2013 at 2:21 pm #116367Hi!
We added the functions_exist() checks and I expect the next update on Friday.
Best regards,
Peter
-
AuthorPosts
- The topic ‘Load helper-post-format.php from child theme’ is closed to new replies.