• Hi everyone

    I working on my of my full-length no side-bar page template, I like to use one of the functions from home page, so I use get_temmplate_part, it does show up, but not 100% show up, I missed the text, and no error shows up, how can I fix it?
    Not sure where I should put this two function I search online might help my case?

    <?php wp_reset_postdata(); ?>
    <?php wp_reset_query();?>

    Thanks!

    <?php
    /* Template Name: Full-width template
    */
    
    $thumbnail_url= wp_get_attachment_url(get_post_thumbnail_id($post->ID));
    
    get_header();
    ?>
    
    <?php if(has_post_thumbnail()) {?>
    <div class="div-block-21 contact" style="background:url('<?php echo $thumbnail_url?>') no-repeat; background-size:cover;" >
     <h1 class="heading-12"><?php page_title();?></h1>
    </div>
    <?php } else { //fallback image ?>
      <div class="div-block-21 contact">
       <h1 class="heading-12"><?php the_title();?></h1>
      </div>
    
    <?php } ?>
    
    <div>
    <div class="div-block-39">
     <div class="div-block-38">
       <?php while(have_posts()) : the_post()?>
       <p class="paragraph-15"> <?php the_content();?> </p>
       <?php endwhile;?>
     </div>
    </div>
    </div>
    
    <?php
    get_template_part('template-parts/content','signup');?>
    
    <?php get_footer();?>

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi,

    Please make sure that the file is in correct directory.
    Ex:
    theme-directory/template-parts/content-signup.php
    Then you can use:
    get_template_(‘template-parts/content’, ‘signup’);

    You can put wp_reset_postdata and wp_reset_query after the endwhile loop

    • This reply was modified 6 years, 9 months ago by necafasu.

    get_template_part( 'template-parts/content','signup' ) is going to load template-parts/content-signup.php. What is in this template? What context is it used in on other pages?

    mydigitalpianoreviews

    (@mydigitalpianoreviews)

    i managed to fixed it using this theme, see example:
    Review here

    Thread Starter madebymt

    (@madebymt)

    @necafasu

    Thanks for your response.
    I think it does link correct, because there no error, and did show some part of my content, but not all.

    Correct one image:https://ibb.co/hNR0qx
    But show up like this:https://ibb.co/kbN6Vx

    Thread Starter madebymt

    (@madebymt)

    @jakept

    Thank you for the comment. here’s my template sign up page code, there’s no loop, so I not sure about reset query.

    Correct one image:https://ibb.co/hNR0qx
    But show up like this:https://ibb.co/kbN6Vx

    Thank you so much for your help!

    <?php
    $sign_up_title = get_field('sign_up_title');
    $sign_up_intro = get_field('sign_up_intro');
    $sign_up_form = get_field('sign_up_form');
    $button_text_top = get_field('button_text_top');
    
    ?>
    
    <div class="div-block-17">
      <div class="container div-block-16 home-signup">
        <div class="row" style="background:none;">
    
          <div class="col-sm-8">
            <p class="lead">
              <strong class="signup"><?php echo $sign_up_title;?></strong> <?php echo $sign_up_intro;?>
            </p>
          </div>
          <!-- end col -->
    
          <div class="col-sm-4">
            <button class="btn btn-success btn-lg btn-block" data-toggle="modal" data-target="#myModal">
             <?php echo $button_text_top;?>
            </button>
          </div>
          <!-- end col -->
        </div>
        <!-- row -->
      </div>
    </div>
    
    <!-- Modal wrapper -->
    <div class="modal fade" id="myModal">
      <div class="modal-dialog">
        <div class="modal-content">
    
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
            </button>
            <h4 class="modal-title" id="myModalLabel">
              <i class="fa fa-envelope"></i> Download this cool Toolkit PDF</h4>
          </div>
          <!-- modal-header -->
          <div class="modal-body">
            <p>Simply enter your name and email! As a thank you for joining us, we're going to give you one of our best-selling courses, <em>for free!</em></p>
              <?php echo $sign_up_form;?>
            <hr>
            <p>
              <small>By providing your email you consent to receiving occasional promotional emails & newsletters. <br>No Spam. Just good stuff. We respect your privacy & you may unsubscribe at any time.</small>
            </p>
          </div>
          <!-- modal-body -->
        </div>
        <!-- modal-content -->
      </div>
      <!-- modal-dialog -->
    </div>
    <!-- modal -->
    Thread Starter madebymt

    (@madebymt)

    @mydigitalpianoreviews

    Not quite sure what you mean.
    Thanks!

    That template part depends on fields like sign_up_title and sign_up_intro being set on the page. Does the page you’re including this template on use those fields?

    Thread Starter madebymt

    (@madebymt)

    @jakept
    Thanks again for your response.
    I got it! It’s advanced custom field problem
    Thank you so much!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘get_template_part is not working correctly.’ is closed to new replies.