Example code
Step 1
XTRA
Using WordPress action add content or PHP codes
In the following example you can see how to add content or PHP codes after portfolio archive pages.
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 | |
/** | |
* With this function you can add any content or php codes after post type archive pages. | |
* | |
* @var $post_type will return current post type name | |
*/ | |
function my_prefix_after_archive( $post_type ) { | |
if ( $post_type === 'portfolio' ) { | |
echo 'This content will show up before portfolio posts.'; | |
} | |
} | |
add_action( 'codevz/archive/after', 'my_prefix_after_archive' ); |
XTRA
How and where should I add this PHP codes?
Best solution is to add custom actions and filters in Child Theme functions.php file. But also you can create your own plugin and use this codes in your plugin.
No comment