Wordpress

<?php
           add_filter( 'default_content', 'custom_editor_content' );
              function custom_editor_content( $content ) {
                 global $page_type;
                 $page_type = is_page_template('Lessons.php');
                 
                 if ( $page_type ) {
                    $content = '
                      <div id=”Tabs”>
                                 <ul>
                                            <li id="li_tab1" onclick="tab(‘tab1')"><a>Watch</a></li>
                                            <li id="li_tab2" onclick=”tab('tab2')”><a>Read/Listen</a></li>
                                            <li id="li_tab3" onclick=”tab('tab3')”><a>Recall</a></li>
                                            <li id="li_tab4" onclick=”tab('tab4')”><a>Understand</a></li>
                                 </ul>
                      <div id="Content_Area">
                      <div id="tab1">
                                 <p>This is the text for tab 1</p>
                      </div>
                      <div id="tab2">
                                 <p>This is the text for tab 1</p>
                      </div>
                      <div id="tab3">
                                 <p>This is the text for tab 1</p>
                      </div>
                      <div id="tab4">
                                 <p>This is the text for tab 1</p>
                      </div>
 
                      
                    ';
                 }
                 else {
                    $content = '
         
                       // TEMPLATE FOR EVERYTHING ELSE
         
                    ';
                 }
                 return $content;
               }
        ?>

Why does this throw an error in the onclick section? (I have the javascript code elsewhere). The goal is to include this dynamic content by default in wordpress. but it won’t let me call the function within onclick.

I notice a lot of “bad quotes” in your code. If this code was copy & pasted from somewhere you will need to fix the bad quotes.

Example:

These are not real double quotes:

<div id=”Tabs”>

Should be

<div id="Tabs">

The first single quote before tab1 is invalid:

onclick="tab(‘tab1')"

Should be

onclick="tab('tab1')"

etc…

Sponsor our Newsletter | Privacy Policy | Terms of Service