• Resolved woodypad

    (@woodypad)


    Hello,
    there is a way to use Code Snippets to inject some code in a point of the site, perhaps referring to a class or to wordpress hooks. I am using another plugin to do this, but I would like to use yours only.
    I’m trying to do two things, 1 – insert a before / after element of a block or paragraph or class.
    2 – I would not like to modify the theme files and I would like to insert the injected modification in a given file, without actually modifying it.
    Is it possible to do it?

    Thank you

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi @woodypad,

    Code Snippets doesn’t really inject code in files, technically speaking. Instead, you need to make use of WordPress action and filter hooks to determine where and when your code is executed.

    If you take a look at the file you want to inject code in and see a call to the do_action or apply_filter function, then you’re in luck – you can use add_action or add_filter to hook in and add code there. If these functions are not used, then it gets significantly harder to alter things.

    You can see a full list of the action and filter hooks on the WordPress Developer site. A lot of themes and plugins also have documentation on this if you don’t want to dig into the code.

Viewing 1 replies (of 1 total)

The topic ‘Inject code’ is closed to new replies.