0

I know I can add some codes using:- is_front_page

But, I want to add different codes into footer of different post types. Then what can I use instead of is_front_page

1

You can use is_singular() instead.

According to Codex, you can use this function the following way:

is_singular($post_type);

Then you can print your desired code into footer the following way:

function my_footer_code() {
    if ( is_singular('my-post-type') ){
        //Your code here
    }
}
add_action('wp_footer','my_footer_code');
  • It's not working in my case. Please visit my site grabsale.in You can see I have added a line "It will show only on homepage" above my footer in homepage. I want to add different texts (store descriptions) in different store pages. Please tell me how can I do it? – Akash Apr 9 '17 at 10:03
  • @ShibamKar I can't see the line you mentioned. Are you sure you are using the right post type? And where are you using this code? I tested the code before posting the answer. – Jack Johansson Apr 9 '17 at 16:56
  • I am using it on footer.php – Akash Apr 11 '17 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.