How to create wordpress custom filter hook

How to create wordpress custom filter hook

This is just an example explaining how to create a wordpress custom filter hook Let's say you have a page or a plugin displaying posts/custom posts based on a certain criteria Now you wish to provide a hook to the end user to be able to modify how the posts get displayed. Here is a sample code to display posts using a standard wordpress loop [crayon-59c674cc2f71a947220084/] Note that we have displayed the  posts after getting the contents in a variable named $wpi_snippet_view. This helps us to define a hook to be able to modify this variable. Below code shows how to define our custom filter hook [crayon-59c674cc2f725461409292/] The only difference is the above code is line number 19 where we have defined the custom hook as wpi_snippet_view_hook Now that the custom hook is defined, all we need to do is to call the hook in our functions.php and modify the variable $wpi_snippet_view to show the required output. [crayon-59c674cc2f72a238003212/] Using the above hook we have changed the thumbnail size from thumbnail to...
Read More