How to fix a special Wordpress theme for working with plugins?

This is my first attempt at coding a custom Wordpress theme, and I'm almost there. There are a few mistakes as there is something, but I tried several different options when fixing them, but without success.

Link: www.studiosimplicit.com/wp.

My first problem is with the nivo slider on the events page (www.studiosimplicit.com/wp/events). Initially, I had a problem with the plugin itself, where the images stacked on top of each other. To fix this, I manually entered the code to call the nivo.js files, and this seems to fix this problem. But now there is a boot image, but the images do not load.

I checked the url of the images and that is not a problem. I also enabled the post-thumbnails feature (as suggested on the nivoslider website as a general fix for my problem), but didn't seem to fix it. It costs nothing when I switch to the default theme, the slider works fine. This is when I activate my own theme, which it breaks.

My second problem is with a plugin that should set a full-screen background image, automatically resized to fit the width of the browser. Again, the plugin works when I switch to the default theme, but it breaks when I switch to my own theme.

Please, help!

+6
source share
3 answers

By the sounds of this, your custom theme lacks common interceptors that allow plugins to modify / display their code.

To make a simple example, each topic should have a wp_head () call somewhere in the <head> section of the output page. This allows the plugin to "connect" to your <head> and, for example, output code to load its Javascript.

Here is a real life example. The WordPress Theme Twentyeleven has this in the header.php file (traditionally this is part of the theme that displays the <head> section on any page):

 ... other <head> stuff wp_head(); ?> </head> 

WP Nivo Slider uses this code when it calls wp_enqueue_script , for example, in its wp-nivo-slider.php . Behind the scenes, wp_enqueue_script uses the wp_head() tag in the wp_head() theme to display the requested Javascript in the <head> section (along the second wp_print_head_scripts that ends in wp_print_head_scripts by default.)

So, in principle, if the plugin works with the provided theme, but does not work with your custom theme, your task is to find the hooks that are not in your theme that the plugin is trying to use.

If you check the documentation for developing a WordPress theme , you will find a list of hooks that the themes should include in the “Plug-in API Interceptors” section. This, in particular:

  • wp_head
  • wp_footer
  • wp_meta
  • comment_form

Important for most plugins will be wp_head and wp_footer . This is where most Javascript is included in the “Header” or “Footer” section (immediately before the closing <body> ).

Most plugins, such as Javascript sliders, image galleries, etc., simply add a new script or two to the <head> or footer section of the website and possibly include CSS files to style their contents, again in <head> , therefore, these two are usually the only necessary hooks.

So, my initial advice was to make sure your custom theme includes a wp_head() call at the end of the <head> section (copy the code from this working theme that you have), as well as a wp_footer() call, before closing </body> . The chances are good that most Javascript plugins will work on them.

+18
source

Just for the record: I had a similar problem and I had to replace the line

 <?php echo get_the_content() ?> 

with this:

 <?php echo the_content() ?> 

But I also had to enable wp_head and wp_foot, as Matt explained.

+1
source

just turn it on

 <?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); ?> <?php wp_head()?> 

in front of his head, and after that he will definitely work.

0
source

Source: https://habr.com/ru/post/910452/


All Articles