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 Answer 1

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');
3
  • 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, 2017 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.
    – Johansson
    Apr 9, 2017 at 16:56
  • I am using it on footer.php
    – Akash
    Apr 11, 2017 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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