Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在现有PHP标记中添加_permalink_Php_Wordpress - Fatal编程技术网

在现有PHP标记中添加_permalink

在现有PHP标记中添加_permalink,php,wordpress,Php,Wordpress,我在Wordpress循环中有这段代码,用于检查字段“quote”是否存在。如果它不在这里,它将显示链接,但如果它在那里,它不会 <?php if(get_field('quote') == ''){ $yourTag = "<a href="the_permalink();">" ; } else { $yourTag = ""; } ?> 您可以使用dot(.)来完成,如下图所示 <?php if(get_field('q

我在Wordpress循环中有这段代码,用于检查字段“quote”是否存在。如果它不在这里,它将显示链接,但如果它在那里,它不会

<?php 
  if(get_field('quote') == ''){
  $yourTag = "<a href="the_permalink();">" ;
  } else {
  $yourTag = "";
  }
?>

您可以使用dot
(.)
来完成,如下图所示

 <?php 
      if(get_field('quote') == ''){
      $yourTag = "<a href='".get_the_permalink()."'>" ;
      } else {
      $yourTag = "";
      }
    ?>

谢谢。如果我的回答对你有帮助,请将其标记为正确:)我还要再等3分钟…:)
<!-- Main Loop =========================================== -->


<div class="container blog-card-container">
    <div class="card-columns">


        <?php if ( have_posts() ) : ?>

            <?php /* Start the Loop */ ?>

            <?php while ( have_posts() ) : the_post(); ?>




                <!-- Conditional a  =========================================== -->

                <?php 
                if(get_field('quote') == ''){
                $yourTag = "<a href="the_permalink();">" ;
                } else {
                $yourTag = "";
                }
                ?>





                <div> <?php echo $yourTag; ?> </div>




                    <div class="card">





                        <!-- Image if loop =========================================== -->

                        <?php if ( in_category('14') ) : ?>


                            <div class="client-header-logo-card" style="background-color: <?php the_field('client_brand_colour'); ?>;">
                                <?php 

                                $image = get_field('client_logo');

                                if( !empty($image) ): ?>

                                    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />

                                <?php endif; ?>
                            </div>              

                        <?php else: ?>

                            <div class="blog-thumb-container">
                                <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?>
                            </div>                          

                        <?php endif ?>




                        <!-- Meta Data if loop =========================================== -->

                        <div class="blog-clients-card-block">

                            <?php if ( in_category('14') ) : ?>

                                <div class="client-text-block">

                                    <p class="blog-cat-label"><?php the_category(', '); ?></p>

                                    <h2><?php the_title(); ?></h2>

                                    <?php if( get_field('quote') ): ?><p class="client-quote"><span style="color:<?php the_field('client_brand_colour'); ?>; font-weight:bold;">&ldquo; </span><?php the_field('quote'); ?><span style="color:<?php the_field('client_brand_colour'); ?>;font-weight:bold;"> &rdquo;</span></p><?php endif; ?>


                                    <?php if( get_field('quote_name') ): ?><p class="client-name" style="color:<?php the_field('client_brand_colour'); ?>;"><?php the_field('quote_name'); ?></p><?php endif; ?>
                                    <?php if( get_field('quote_position') ): ?><p class="client-position" style="color:<?php the_field('client_brand_colour'); ?>;"><?php the_field('quote_position'); ?></p><?php endif; ?>


                                    <?php if( get_field('button_text') ): ?>
                                        <a class="btn btn-sm btn-client-archive" href="<?php the_permalink(); ?>" style="background-color:<?php the_field('client_brand_colour'); ?>;" role="button"><?php the_field('button_text'); ?></a>
                                    <?php endif; ?>

                                    <?php if( get_field('video_url') ): ?>
                                        <div class="embed-container">
                                            <?php the_field('video_url'); ?>
                                        </div>
                                    <?php endif; ?>       

                                </div>

                            <?php else: ?>

                                <p class="blog-cat-label"><?php the_category(', '); ?></p>
                                <h2 class="blog-card-title"><?php the_title(); ?></h2>
                                <p class="card-text"><?php the_excerpt(__('(more…)')); ?></p>
                                <p><strong><?php the_author(); ?></strong> | <?php the_date(); ?> </p>

                            <?php endif ?>


                        </div>





            </a>





        </div>



        <?php endwhile; wp_reset_postdata(); endif; ?>



    </div>

</div>
 <?php 
      if(get_field('quote') == ''){
      $yourTag = "<a href='".get_the_permalink()."'>" ;
      } else {
      $yourTag = "";
      }
    ?>