• Resolved martinfamily2005

    (@martinfamily2005)


    I am trying to recreate the functionality on this page in WordPress: https://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: https://billboardfamily.com/our-reviews/

Viewing 15 replies - 1 through 15 (of 38 total)
  • Thread Starter martinfamily2005

    (@martinfamily2005)

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

    Thread Starter martinfamily2005

    (@martinfamily2005)

    Here is the code for the entire page:

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

    Thread Starter martinfamily2005

    (@martinfamily2005)

    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>
    Thread Starter martinfamily2005

    (@martinfamily2005)

    <—— Pulling Hair Out

    Anyone?

    Thread Starter martinfamily2005

    (@martinfamily2005)

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

    Thread Starter martinfamily2005

    (@martinfamily2005)

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

    Thread Starter martinfamily2005

    (@martinfamily2005)

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

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

    Try this.

    Thread Starter martinfamily2005

    (@martinfamily2005)

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

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

    Thread Starter martinfamily2005

    (@martinfamily2005)

    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: https://wordpress.pastebin.com/91A8T5db

    `

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

    EDIT: I got it.

    Thread Starter martinfamily2005

    (@martinfamily2005)

    <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>
    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;?>

    Thread Starter martinfamily2005

    (@martinfamily2005)

    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

Viewing 15 replies - 1 through 15 (of 38 total)
  • The topic ‘Can someone please help me figure this out????’ is closed to new replies.