1

So, what I am trying to do is creating a slideshow plugin that won't require end user to write a single line of code. I can't use custom posts because I need to keep it simple for the end user.

Is there a hook or a filter that would let me include my php generated code right after the

body_class() ?

Is it true that the only hook I can use is

the_content() ?

Thank you.

2 Answers 2

0

As every theme is different you can't really expect a plugin to know where to put the slideshow in.

As you say the best place would be the content filter if that's where you want it. If you want it anywhere else you could inject it after using jquery?

6
  • I know that every theme is different but there are also best practice ( like using body_class() or wp_head() or the_content() ). Anyway in 2017 best solution is still jQuery? Commented Nov 15, 2017 at 12:24
  • The simplest way I have seen yet is to use a shortcode. When the slideshow is created, display the code to copy / paste by the user and the user pasts it at the place he chooses in a page.
    – mmm
    Commented Nov 15, 2017 at 12:56
  • @mmm yes, the shortcode is the easiest way, but what if the user is so unable that he will mess it up anyway? Commented Nov 15, 2017 at 13:17
  • Then do it for them? is this a plugin that will go on the repository of custom plugin just for you?
    – Tom Webb
    Commented Nov 15, 2017 at 13:32
  • if a user is not able to paste a shortcode, he certainly cannot past his username and password then the backoffice will be ease of this calamity.
    – mmm
    Commented Nov 15, 2017 at 15:07
0

The body_class() functions also offers a filter, if that's what you're looking for:

add_filter('body_class', 'my_body_classes');
function my_body_classes( $classes ) {

    // Your code here

    return $classes;
}

However, if you want to add the content inside the body right after it starts, that would probably not possible. Unless there is a custom function right after the body tag that can be hooked into, there is no easy way to do this.

You can do a full preg_replace() on pages though, but it is most likely costly.

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.