Support » Fixing WordPress » Getting in jquery function

  • Shay

    (@shaypessah)


    I currently have code in my header to show an image show in a specific div when clicked. What I would like to do, is have the content show in another div. I managed to get the content to show (outside php), but was wondering if there was a way to get the content from that post to show. The code is below and in script tags. Any advice?

    ‘$(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’));
    }
    });
    });’

Viewing 8 replies - 1 through 8 (of 8 total)
  • billcolumbia

    (@billcolumbia)

    Try replacing ‘$’ with ‘jQuery’. I think wordpress reserves $ for something else.

    Shay

    (@shaypessah)

    Which ‘$’? The script works, just the <?php get_the_content (); ?> doesnt.

    billcolumbia

    (@billcolumbia)

    I don’t think get_the_content returns the info. I think the_content does. If you use get_the_content you need to store it in a variable or something.

    Shay

    (@shaypessah)

    It still didn’t work with the_content. I wonder if the way I have the code, its trying to print the content from the image itself and not the post.

    billcolumbia

    (@billcolumbia)

    Is your code inside the loop?

    Shay

    (@shaypessah)

    Yes it is.

    billcolumbia

    (@billcolumbia)

    Interesting. Sorry I couldn’t help.

    Shay

    (@shaypessah)

    It’s ok. It’s all a learning experience 🙂 Thank you for your help!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Getting in jquery function’ is closed to new replies.