- xaraboo October 27, 2017 at 4:24 pm
I need a little direction on how to hook into the filer:
nice_post_footer_meta_template
to disable the file, comment-count, and tags.I thought I could set the default
echo => false
but have not been able to get it work.Thanks.
Juanfra Aldasoro October 27, 2017 at 5:49 pmHello,
Thank you for writing.
The nice_post_footer_meta_template only gives the template in which the footer meta will be displayed. It doesn’t have an “echo” parameter. Would you please tell me what you are doing exactly and what you want to do?
Thank you,
Juan.xaraboo October 30, 2017 at 4:01 pmI would like to be able to remove the file, comment count, and tags from the footer meta. To solve the problem, I simply edited the `child-theme/includes/template-tags.php function nice_post_footer_meta( ) and set the $defaults->echo = false;
Juanfra Aldasoro October 30, 2017 at 6:08 pmHi,
Thank you for the follow-up.
The file includes/functions.php cannot be overridden on a child theme basis. It has sensitive functions in order to make the theme work.
The whole idea of filters is that you can add hooks to them from outside the function in which they are declared. So, to achieve what you want to do, it would be better to define something like this in the smart-child/functions.php file:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters<?php //* Do NOT include the opening php tag add_filter( 'nice_post_footer_meta_args', 'nice_post_footer_meta_my_args' ); function nice_post_footer_meta_my_args( $args ) { $args['echo'] = false; return $args; } You can read more about hooks in the WordPress documentation portal: https://codex.wordpress.org/Plugin_API#Hooks:_Actions_and_Filters
Best,
Juan.Juanfra Aldasoro October 31, 2017 at 8:22 pmHi,
Thanks for the follow-up.
That’s great
Have a nice day,
Juan.xaraboo October 31, 2017 at 8:35 pmSo I get the principles behind add_filters, but say for example, how do I determine what I’m supposed to pass to turn off the post_author and date in the
nice_post_meta_template
?I see where it defines
$nice_post_meta_tpl = '[post_author_posts_link] [post_date [post_categories] [post_comments] [post_edit]';
but I’m not understanding how to I would change that for the entire template.Thanks
Juanfra Aldasoro October 31, 2017 at 9:00 pmHi,
Thanks for the follow-up.
The acronym tpl stands for template. So, the hook nice_post_meta_template can be used to alter that template. The elements with square brackets are used as placeholders.
For example, if you want to remove the author and date, you can redefine the template to only include this:
$nice_post_meta_tpl = '[post_categories] [post_comments] [post_edit]';
(Please note how I’ve removed the two first elements).
Please be sure to use the appropriate filter and don’t modify the function in includes/template-tags.php
Best,
Juan.Juanfra Aldasoro October 31, 2017 at 9:39 pmMy pleasure! the magic of filters.
Have a nice day,
Juan.
This topic is marked as resolved
Only the topic author can re-open this thread.