I have a file named custom.php where i have the following javascript code

        <script type="text/javascript">
        $(function () {
        $('.mainContent').hide();
        $('a.read').click(function () {
        $(this).parent('.excerpt').slideUp(10);
        $(this).closest('.tenant').find('.mainContent').slideDown(10);
//      $('.mainContent').show();
        return false;
        });
        });
        </script>

i am using this javascript to expand posts on the custom.php page in this manner

<?php echo "<div class="tenant">"; 
echo "<div class="excerpt">";
the_excerpt();
echo "<a href="" class="read">Read More</a>n";
echo "</div>";
echo "<div class="mainContent">";
the_content();
echo "</div>";
echo "</div>"; 
?>

when i use the same php code in functions.php , it works but does not load the javascript code from custom.php so full post is shown instead of the excerpt

WHAT TO DO?
ANY HELP?

Read more here: calling function in functions.php wordpress


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: