0

I am trying to figure out a way to remove permalink's from posts with the category 'nolink'. I have tried a few java script attempts - but have not managed to get it to work.

<?php 
query_posts( 'tag=Client-list' );
while ( have_posts() ) : the_post();
    echo '<ul class="client-thumb-wrap">';
        echo '<a href="';
            the_permalink();
        echo '">';
            echo '<li class="'; 
                $category = get_the_category( $custompost );
                echo $category[0]->cat_name ;
                    echo ' ';
                echo $category[1]->cat_name ;
                    echo ' ';
                echo $category[2]->cat_name ;
                    echo ' ';
                echo $category[3]->cat_name ;
            echo '">';

            echo '<img src="';
            the_field('client_logo');
            echo '">';
        echo '</li>';
    echo '</ul>';
endwhile;
wp_reset_query();
?>
4

1 回答 1

1

has_term允许您检查帖子是否已分配(或未分配)特定术语,请尝试:

$href = ( has_term( 'nolink', 'category' ) ) ? '#' : get_permalink();
echo '<a href="' . $href . '">';
于 2013-04-25T11:23:22.410 回答