2

On my site have a custom post type with this info. I stored the file in single-{customposttype}.php.

<?php
get_header();
?>
<div style="width:500px;">
<?php
$id = get_the_id();
echo do_shortcode( '[skwidget id="' .  $id . '"]' );
?>
</div>
<?php get_footer(); ?>  

The skwidget plugin is called correctly and everything seems to work fine.

But here's the issue: Everything gets included but I ONLY want the css for the theme, css for the plugin and all relevant css/js for the plugin but I don't want header and footer-menu(s) to be shown. How do I achieve that?

If just remove get_header() and get_footer() then the plugin won't work because it needs js/css etc.

I GUESS I could create header html and footer manually but that doesn't seem like a good idea...

4
  • You can create a custom function to be called after your get_header() call. You can include wp_dequeue_script() and wp_dequeue_style() for all the unnecessary scripts and styles. References: codex.wordpress.org/Function_Reference/wp_dequeue_script codex.wordpress.org/Function_Reference/wp_dequeue_style – Rohit Pande Jan 6 '16 at 14:17
  • Ok, but how that help me removing menus? – bestprogrammerintheworld Jan 6 '16 at 14:21
  • Okay. The other way around is remove your header and footer calls and use wp_enqueue_script() and wp_enqueue_style() functions for necessary scripts and styles and get your thing working. – Rohit Pande Jan 6 '16 at 14:25
  • @RohitPande - It was not that I was looking for but you got me thinking a little differently and I came up with a solution. I've answered my own question in case someone stumble upon on the same issue. – bestprogrammerintheworld Jan 6 '16 at 14:40
3

If someone needs something similar, I actually found an answer to my issue and it is to pass arguments to get_header() and get_footer().

<?php
get_header('customposttype);
?>
<div style="width:500px;">
<?php
$id = get_the_id();
echo do_shortcode( '[skwidget id="' .  $id . '"]' );
?>
</div>
<?php get_footer('customposttype'); ?>  

and copy header.php to header-{customposttype}.php and footer.php to footer-{customposttype}.php

And after that custom modifiy the

header-{customposttype}.php
footer-{customposttype}.php

after your needs!

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.