WordPress.org

Ready to get started?Download WordPress

Forums

getting the_content in a jquery img .on click (1 post)

  1. Shay
    Member
    Posted 1 year ago #

    I've been trying to get my content from posts to show up in a specific div but can't get <?php the_content ?> to populate. When I replace it with text, it shows up. Any help?

    Current code:

    $(document).ready(function() {
    	  $("img").click(function () {
    		  if ($(this).hasClass("profiles")) {
    		 	$('#student_area').empty()
    		    var img = $('<img />').attr({ 'src': $(this).attr('src'), 'alt': $(this).attr('alt') }).appendTo($('#student_area'));
    			$("div.student_desc").empty()
    			var div = $('<div><?php get_the_content (); ?>This is the content</div>').attr({ 'alt': $(this).attr('alt') }).appendTo($('div.student_desc'));
    		  }
    	   });
    	});

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser.]

Topic Closed

This topic has been closed to new replies.

About this Topic