Pawel Slabiak
Forum Replies Created
-
Forum: Themes and Templates
In reply to: [Twenty Twenty] Filtering meta on CPTThank you, @stilman-davis. In the thread you reference, the advice seems to be to modify functions directly in template-tags.php (if I’m reading correctly). Doing so definitely works but also seems to be a sure way to lose changes whenever the theme updates.
My question here is motivated by the assumption that modifying template-tags.php in the parent theme is not a sustainable way to use a filter defined therein. Any help in understanding how to correctly use the filter from the child theme or explanation of why doing so is impossible would be welcome.
Forum: Themes and Templates
In reply to: [Twenty Twenty] Filtering meta on CPTMy understanding of the code lines referenced in the original post is that
the first argument of apply_filters() creates a filter hook.Hence, twentytwenty_disallowed_post_types_for_meta_output is a filter hook.
The apply_filters() function creates an array of disallowed post types and stores the array in $disallowed_post_types, I think.
To add additional post types, such as my registered custom post type called ‘qualia’, it seems one should be able to use a custom function hooked into the filter hook, like so:
function be_my_function($disallowed_post_types) { $disallowed_post_types[] = 'qualia'; // add 'qualia' to the array return $disallowed_post_types; } add_filter('twentytwenty_disallowed_post_types_for_meta_output', 'be_my_function');
The above code has no effect when placed in the child theme’s functions.php. The code is likely wrong or in the wrong file, or both.
Any hints or tips on whether this is the right direction or how to correctly use the filter would be appreciated. This would be useful for all kinds of custom post types where displaying meta does not make much sense.
Forum: Themes and Templates
In reply to: [Twenty Twenty] Filtering meta on CPTThank you, @stilman-davis—I neglected to say in the original post that copying the inc folder (and the template-tags.php file it contains) to the child theme and adding an element to the array in the filter definition has no effect on the meta display.
Two things are clear: 1. modifying the array in the filter definition in the parent theme does work and 2. these changes will be lost when the theme updates.
Therefore, it seems that the proper use of the filter is to hook into it from a child-theme location (e.g. functions.php or a template or a template part) or from a plugin and pass a custom post type to its array, which in the original definition has only one element, ‘page’.
But I don’t yet know how to do so.
Forum: Plugins
In reply to: [External Links - nofollow, noopener & new window] AMP removes leading marginAs noted in the original post, reintroducing the CSS in the customizer or the child-theme stylesheet has no effect, despite the css targeting the classes that remain associated with the element after tree shaking.
Again, any ideas about a workaround would be appreciated.
Forum: Plugins
In reply to: [Display Posts - Easy lists, grids, navigation, and more] unlinking filterMany thanks for taking the time to write and post this snippet.
The code you shared is more helpful than any tips or advice I could’ve hoped for—much appreciated!- This reply was modified 4 years, 9 months ago by Pawel Slabiak.
Regarding unlinking post titles, the code you reference might not be the problem.
When I use the code you refer to (via Code Snippets plugin) it has the intended effect: all post titles shown by Display Posts plugin appear without hyperlinks.