• We have a custom widget based on vc_infobox. It lays out a grid of focus areas for which we have online learning modules. Everything is working fine in WP 4.7.6. When we upgraded to WP 4.7.8 (or higher) the link associated with each focus area in the grid is empty. Below is our code for retrieving the focus areas and creating the box for each. It looks like the_permalink() is returning an empty string for the current post. Now, all focus areas link back to the current page. I need help trying to find out why the permalink is empty after the WP upgrade.

    
            <ul id="focus_areas_list">
            <?php $this_term = get_queried_object();
                $args = array(
                    'parent' => $this_term->term_id,
                    'orderby' => 'slug',
                    'hide_empty' => true
                );
    
                $child_terms = get_terms( $this_term->taxonomy, $args );
    
                foreach ( $child_terms as $term ): 
    
                    $query = new WP_Query( 
                        array(
                            'post_type' => 'sfwd-courses',
                            'tax_query' => array(
                            'relation' => 'AND',
                                array(
                                  'taxonomy' => $this_term->taxonomy,
                                  'field'    => 'slug',
                                  'terms'    => array( $term->slug )
                                )
                            )     
                        ) 
                    );?>
                    <h3 class="child_term"><?php echo $term->name; ?></h3>
                    <?php if ( $query->have_posts() ): ?>
                       <?php while($query->have_posts()) : $query->the_post(); ?>
                            <li id="module-<?php the_ID(); ?>" class="medium-4 columns single_f_area">
                                <a href="<?php the_permalink(); ?>
                                    <div class="medium-12 columns thumb_image" style="background: url(<?php if ( has_post_thumbnail() ) { the_post_thumbnail_url(); } ?>) no-repeat center; background-size:cover;">
                                        <h5>
                                            <?php the_title(); ?>
                                            <?php if ( !empty( get_the_excerpt() ) ): ?>
                                                <span class="cat_description"><?php echo wp_trim_words( get_the_excerpt(), '10' , '...'); ?></span>
                                            <?php endif; ?>
                                        </h5>
                                    </div>
                                    <h6 class="f_area_home_title module_page">
                                        View Module
                                    </h6>
                                </a>
                            </li>
                        <?php endwhile; ?>
                    <?php endif; ?>
                <?php endforeach; ?>

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @cuelearn

    It looks like there’s a missing " and > on the permalink and that line should be: <a>">

    That said, your HTML is also malformed because you have an h3 tag directly inside your UL. Moving your UL item to after the <?php if ( $query->have_posts() ): ?> line and before the <?php while ( $query->have_posts() ): $query->the_post(); ?> line should fix the problem. You’re also missing the closing UL tag, but it could have just been missed when copy/pasting code here. You’d also need to move the closing UL tag to between the <?php endwhile; ?> <?php endif; ?> lines.

    Here’s the corrected code:
    https://pastebin.com/NUGSZ7Ba

    • This reply was modified 7 years, 2 months ago by Brett Shumaker. Reason: Moved code block to pastebin
    Thread Starter cuelearn

    (@cuelearn)

    Thank you Brett for your reply and help. I tried your suggestion but my link is still empy when the anchor element for each focus area is created. Below is the output.

    <li class="medium-4 columns single_f_area">
      <strong><a href=""></strong>
        <div class="medium-12 columns thumb_image" style=" background:url(https://cuelearntest1.wpengine.com/wp-content/uploads/2017/05/53-6.jpg) no-repeat center; background-size:cover;">
          <h5>Behavioral Health in Primary Care (SIM Initiative)</h5>                                                                           
        </div>
        <h6 class="f_area_home_title">View Modules</h6>
      </a>
    </li>

    I suspect the link may not be in the custom control, but I’m at a loss as to what changed in WP to make this not work. Our test environment only has the WP upgrade and the problem exists there too. 4.7.6 works fine but 4.7.8 and forward is broken.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘permalink value empty after upgrade to WP 4.7.8 and higher’ is closed to new replies.