0
votes

I want have the structure of posts on wordpress site enter link description here

The top row name (slug) posts:

<?php
    $tags = get_categories('orderby=name&taxonomy=references&order=ASC');

    $output = '<table><tr><td> </td>';
    foreach ( $tags as $tag ) {


        $term = get_term_by('id', (int)$tag->term_id, 'references');
        $output .= '<td><a href="' . get_term_link( (int)$tag->term_id, 'references' ) . '">' . $tag->name . '</a></td>';
    }
    echo $output . '</tr>';

?>

Then the left column same name posts:

<?php
    $tags2 = get_categories('orderby=name&taxonomy=references&order=ASC');

    $output = '';
    foreach ( $tags2 as $tag ) {

        $term = get_term_by('id', (int)$tag->term_id, 'references');
        $output .= '<tr><td><a href="' . get_term_link( (int)$tag->term_id, 'references' ) . '">' . $tag->name . '</a></td><td>THIS PLACE -PROBLEM </td></tr>';


    }
    echo $output . '</table>';

?>

I have custom taxonomy "references". Terms in this taxonomy have same name as the name (slug) of post. Even posts link to several term in taxonomy and even term in taxonomy belongs to several posts.

At intersections of of rows and columns I need to get the value (true or false): if the post of the column to the left refers to the post of the top line put the true, if not, false.

1

1 Answers

1
votes

I think it could be resolved if you creat two-dimensional matrix. For example

$tags = get_categories('orderby=name&taxonomy=references&order=ASC');
$tags2 = get_categories('orderby=name&taxonomy=references&order=ASC');

Then

foreach($tags as $v1){
     foreach($tags2 as $v2){
         if( $v1 == $v2 /* some action I haven`t understand what you wrote*/){
            /*output code */
         }
     }
}

Or I have mistake ?