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.

<?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

Leave a Reply

Your email address will not be published. Required fields are marked *