I found a tutorial online which shows how to use a table of content in WordPress. There is a code and the code is
if ( is_page( 'tocbot' ) ) {
wp_enqueue_script(
'tocbot',
plugin_dir_url( __FILE__ ) . 'assets/js/tocbot.min.js',
array(),
'4.3.1',
true
);
} // End if().
The developer said that we need to replace is_page( ‘tocbot’ ) with your desired if conditional depending on where you want to use Tocbot.
I found the tutorial here
2
Answers
Use
is_sgingle()
insted ofis_page()
.List of all WordPress conditionals is here.
In your case for all posts it is will be
is_single
. For posts, pages and post types it isis_singular
.