Forums

[resolved] Can someone please help me figure this out???? (39 posts)

  1. martinfamily2005
    Member
    Posted 1 year ago #

    I am trying to recreate the functionality on this page in WordPress: http://iwearyourshirt.com/testimonials (click on the customers to see the content at the top of the page change)

    I am close, and it works with this code:

    <?php $my_query = new WP_Query('cat=7');
        while ($my_query->have_posts()) : $my_query->the_post();
        $do_not_duplicate = $post->ID;
        ?>
        <div class="reviews-date">
        <?php the_date(); ?>
        </div>
        <a href="#self" onclick="document.getElementById('expansion').innerHTML = '<?php the_title() ?>';">This is an example</a>
        </div>
        <?php endwhile; ?>

    But when I try to add <?php the_content() ?> right after <?php the_title() ?> in the innerHTML portion the entire content is displayed, no links like they are supposed to be.

    The working example is up right now. I can put in the non-working example if you need me to. Thanks.

    The site: http://billboardfamily.com/our-reviews/

  2. martinfamily2005
    Member
    Posted 1 year ago #

    Anyone know why this is happening? I can;t imagine what is so special about the_content() that it breaks innerHTML. Thanks!

  3. martinfamily2005
    Member
    Posted 1 year ago #

    Here is the code for the entire page:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  4. martinfamily2005
    Member
    Posted 1 year ago #

    Does anyone know? Here is the current code to show you how it is when it is NOT WORKING....the the_content() tag totally breaks the innerHTML.

    v id="reviews-leftcolumn">
        <?php $my_query = new WP_Query('cat=7');
        while ($my_query->have_posts()) : $my_query->the_post();
        $do_not_duplicate = $post->ID;
        ?>
        <div class="reviews-row"><span class="reviews-first-row"><a href="#self" onclick="document.getElementById('expansion').innerHTML = '<?php the_content()?>';"><?php the_title(); ?
    
    ></a></span>             <span class="reviews-second-row"><?php the_date(); ?></span></div>
    
        <?php endwhile; ?>
        </div>
  5. martinfamily2005
    Member
    Posted 1 year ago #

    <------ Pulling Hair Out

    Anyone?

  6. martinfamily2005
    Member
    Posted 1 year ago #

    anyone? I really need this to work, but nothing I come up with is working...please help me out!

  7. martinfamily2005
    Member
    Posted 1 year ago #

    This is the last thing on my site that needs fixed....then I can launch. Please help me out!

  8. martinfamily2005
    Member
    Posted 1 year ago #

    This is urgent. Please help me out if you know the answer!

  9. MAS
    Member
    Posted 1 year ago #

    <a href="#self" onclick="document.getElementById('expansion').innerHTML = '<?php the_title('','',false) . get_the_content() ; ?>';">This is an example</a>

    Try this.

  10. martinfamily2005
    Member
    Posted 1 year ago #

    Sorry, that doesn;t work either. Go check it out: http://billboardfamily.com/our-reviews/

  11. MAS
    Member
    Posted 1 year ago #

    <a href="#self" onclick="document.getElementById('expansion').innerHTML = '<?php echo get_the_content()?>';">

  12. martinfamily2005
    Member
    Posted 1 year ago #

    This seems to work for the one post that is text only, but not for the one below that has an image....as you can see. Also, the entire code is not pulling all of the posts from that category for some reason....there are 3 posts total.

    FULL PAGE CODE HERE: http://wordpress.pastebin.com/91A8T5db

    `

  13. MAS
    Member
    Posted 1 year ago #

    which code you use now? give me that line only. i want to see that.

    EDIT: I got it.

  14. martinfamily2005
    Member
    Posted 1 year ago #

    <div id="reviews-leftcolumn">
        <?php $my_query = new WP_Query('cat=7');
        while ($my_query->have_posts()) : $my_query->the_post();
        $do_not_duplicate = $post->ID;
        ?>
        <div class="reviews-row"><span class="reviews-first-row"><a href="#self" onclick="document.getElementById('expansion').innerHTML = 
    
    '<?php echo get_the_content()?>';"><?php the_title() ?></a></span>             <span class="reviews-second-row"><?php the_date(); 
    
    ?></span></div>
    
        <?php endwhile; ?>
        </div>
  15. MAS
    Member
    Posted 1 year ago #

    function testimonialsPOST(){
     global $post;
     $content = get_the_content();
     $content = apply_filters('the_content', $content);
     $content = str_replace(']]>', ']]>', $content);
     return $content;
    }

    Write this code in your functions.php file. Now add this.

    <a href="#self" onclick="document.getElementById('expansion').innerHTML = 
    
    '<?php echo testimonialsPOST();?>';"><?php the_title() ?></a>

    EDIT: <?php echo testimonialsPOST();?> instead of <?php echo testimonialsPOST;?>

  16. martinfamily2005
    Member
    Posted 1 year ago #

    Well, that seems to be a step int he correct direction. Still not there yet, however. Instead of returning the content of the post in the "expansion" div...you get this: testimonialsPOST

  17. martinfamily2005
    Member
    Posted 1 year ago #

    Go check it out ... back to where we started, sort of

    <div id="reviews-leftcolumn">
        <?php $my_query = new WP_Query('cat=7');
        while ($my_query->have_posts()) : $my_query->the_post();
        $do_not_duplicate = $post->ID;
        ?>
        <div class="reviews-row"><span class="reviews-first-row"><a href="#self" onclick="document.getElementById('expansion').innerHTML = 
    
    '<?php echo testimonialsPOST();?>';"><?php the_title() ?></a>;?></span>             <span class="reviews-second-row"><?php 
    
    the_date(); ?></span></div>
    
        <?php endwhile; ?>
        </div>
  18. MAS
    Member
    Posted 1 year ago #

    <?php echo testimonialsPOST();?> instead of <?php echo testimonialsPOST;?>

    I mistake something:) Try above code now. AND `str_replace("]]>", "]]>", $content);
    `

  19. martinfamily2005
    Member
    Posted 1 year ago #

    OK I changed all that ... still the same

  20. MAS
    Member
    Posted 1 year ago #

    http://codex.wordpress.org/Function_Reference/the_content

    SEE Alternative Usage portion. '>' will be >. Here it is suppressed.

  21. martinfamily2005
    Member
    Posted 1 year ago #

    I am lost. Does that give you any ideas on how to make this work?

    I read it and tried the code snippets suggested, which fixed this somewhat, but the contents of the posts are still not going to the"expansion" div.... hmmmmm

  22. MAS
    Member
    Posted 1 year ago #

    give your code in pastebin once.

  23. martinfamily2005
    Member
    Posted 1 year ago #

    ok. here is the entire page code: http://wordpress.pastebin.com/xe2BT8VJ

  24. MAS
    Member
    Posted 1 year ago #

    I updated your code. check this once http://wordpress.pastebin.com/SnbD3vMi

  25. martinfamily2005
    Member
    Posted 1 year ago #

    Still broken.

  26. MAS
    Member
    Posted 1 year ago #

    <a href="#self" onclick=\"document.getElementById('expansion').innerHTML ='<?php echo $content; ?>';\"><?php the_title() ?></a></span>

    Try this now once.

  27. martinfamily2005
    Member
    Posted 1 year ago #

    looks good ... but the links do not work, and the post content is not appearing in the "expansion" div.

  28. MAS
    Member
    Posted 1 year ago #

    take the code from here http://wordpress.pastebin.com/AF6qjURp

  29. martinfamily2005
    Member
    Posted 1 year ago #

    I copied the code directly from there, and put it into the file .... it still is not working.

  30. MAS
    Member
    Posted 1 year ago #

    ok... get this http://wordpress.pastebin.com/0gfGqukT. I write a javascript. check once that.

Topic Closed

This topic has been closed to new replies.

About this Topic