• <?php if ( get_the_term_list( get_the_ID(), 'category1', true) ||  get_the_term_list( get_the_ID(), 'category2', true )) { ?>
    
                            <?php echo get_the_term_list( get_the_ID(), 'category1', "", "", "" ) ?>
                            <?php echo get_the_term_list( get_the_ID(), 'category2', "", "", "" ) ?>
                <?php } ?>

    This code basicly checks both categories if they got something to show and if they do (any of them) , it loads which ever has the info.
    Now i want to create another condition which does this
    <?php if ( $postcount = 1 ) { ?> and <?php if ( $postcount > 1 ) { ?>

    But i couldnt seem to manage it. It doesnt have to have postcount code in it. I just want to filter the output based on the quantity of it.

    I would apriciate any help.

    Thanks.

Viewing 15 replies - 16 through 30 (of 35 total)
  • Thread Starter Aaron

    (@gardi)

    Alright. after carefull examination this is the resulting code .

    <p>ID:819  CAT1:<a href=&quot;https://www.xxx.com/actors/michael/&quot; rel=&quot;tag&quot;>Michael >/a&gt 
    
    CAT2:</p>Yazar<a href="https://www.xxx.com/actos/michael/" rel="tag">Michael</a>

    There were several other listed actors but i deleted them to clear the code.

    Thread Starter Aaron

    (@gardi)

    Ok here is the deal, the forum doesnt allow the broken code to appear. But the first CAT1 is actually like this.

    & l t ; a href= & q u o t ; https://www.xxx.com/actors/michael/& q u o t ; rel=& q u o t ;tag& q u o t ;& g t ;Michael & g t ;/a & g t these are the base codes for the > and < etc. But for some reason, for the first CAT 1 it loaded them as those codes while in CAT 2 they were loaded properly

    Sorry, but I can’t tell what you are getting because the post is not displaying the results properly.

    From what I can tell, it does appear that the debug code is getting cat1 correct. Is this true?

    Thread Starter Aaron

    (@gardi)

    _

    First try putting the code in a pastebin and posting a link here.

    Thread Starter Aaron

    (@gardi)

    Ok so this is the copy paste from the source

    https://pastebin.com/JyS8R20N

    I need the code from the php file that contains the code we are trying to debug, not the output from the screen.

    Thread Starter Aaron

    (@gardi)

    Ups sorry.

    here im sharing the real names of the custom posts.

    https://pastebin.com/TNcZYtrn

    Sorry for the confusion, but you said you are sharing the real names of the custom posts. Did you mean the names of the taxonomies?

    `

    Thread Starter Aaron

    (@gardi)

    Yea yea they are taxonomies. Infact here is the function.php code of them

    https://pastebin.com/XDzNMSNa

    My bad.

    Sorry, but I must continue later.

    Thread Starter Aaron

    (@gardi)

    Alright. Thanks again.

    I want to eliminate all the code not necessary for the debugging. Please post the output from this:

    <?php if ( $cat1 = get_the_term_list( get_the_ID(), 'uyeler', ',', '', '') ||
          $cat2 = get_the_term_list( get_the_ID(), 'kisiler', '', '', '' )) {
    
       $id = get_the_ID();
       $cat1 = get_the_term_list($id, 'uyeler');
       $cat2 = get_the_term_list($id, 'kisiler');
       print_r("<p>ID:$id  CAT1:" . htmlentities($cat1) . ' CAT2:' . htmlentities($cat2) . '</p>');
    
       if ( false && $cat1 && $cat2 ) {
    
          // Plural code
    	  echo 'Yazarlar';
          echo $cat1;
          echo $cat2;
       } else {
          // Singular code
    	  echo 'Yazar';
          echo $cat1;
          echo $cat2;
       }
    } ?>
    Thread Starter Aaron

    (@gardi)

    https://pastebin.com/rr7uTCye

    The results are same.

    Its loading twice first with broken html then with proper one. (so its bypasing the plural or singular condition)

    OK – the calls to get_the_term_list() are working. Please try this modified version:

    <?php $id = get_the_ID();
       $cat1 = get_the_term_list($id, 'uyeler', '', ', ', '');
       $cat2 = get_the_term_list($id, 'kisiler', '', ', ', '');
       // print_r("<p>ID:$id  CAT1:" . htmlentities($cat1) . ' CAT2:' . htmlentities($cat2) . '</p>');
    
    if ( $cat1 && $cat2 ) {
       // Plural code
       echo 'Yazarlar ';
       echo $cat1;
       echo $cat2;
    } elseif ( $cat1 || $cat2 ) {
       // Singular code
       echo 'Yazar ';
       echo $cat1;
       echo $cat2;
    } ?>
Viewing 15 replies - 16 through 30 (of 35 total)
  • The topic ‘get the term list with postcount based output.’ is closed to new replies.