We changed our privacy policy. Read more.

New answers tagged

3

You can use the get_template_part_{$slug} hook, which fires before a template part is loaded. You can find the reference here, which I find more useful than the official reference. So, I tested it in the twentytwentyone theme (yes I modified the theme directly but only for testing). I tested it with the template-parts/content/content-single.php part, and I ...


1

Just call wp_enqueue_script/wp_enqueue_style in the template part file itself.


0

A question very similar to this has already been answered here. Essentially, the solution is to write a function to load your scripts conditionally outside of your site's initial enqueue functions. First, create the functions with the necessary conditionals to load the scripts or styles you want, something like: // Conditional script loading function ...


1

Since WordPress Version 4.7 you can use 'get_theme_file_uri()' which will first look in your child theme folder and afterwards in the parent theme folder. This way, the file in the child theme will be prioritized. wp_enqueue_script('custom-js', get_theme_file_uri() . '/scripts/custom.js');


0

When you enqueue a script with wp_enqueue_script() it adds the <script> tag part for you. If you have HTML that the script interacts with you will need to add that HTML to the page another way. You should not include the script tag in any HTML. There are many options for adding HTML to a page, depending on where you need it: Adding it in the Text tab ...


0

Anyone that has created their admin user from PhpMyAdmin, and comes across this issue - it may be because you have not copied the user_meta row for rich text editing. Simply check, and uncheck the "Disable the visual editor when writing" option in your user profile to test if this will fix your issue.


Top 50 recent answers are included