Last active
July 16, 2024 22:23
-
-
Save tobeyadr/a8901e77630b5df8c8ed4297cb12d63f to your computer and use it in GitHub Desktop.
Pseudo code for the new feature comparison table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$feature_categories = [ | |
'crm', | |
'sales-automation', | |
'marketing-automation', | |
'email-marketing', | |
'integrations', | |
'developer-tools', | |
]; | |
foreach ( $feature_categories as $feature_category ): | |
$term = get_term_by( 'slug', $feature_category, 'feature-category' ); | |
$feature_query = new WP_Query( [ | |
'post_type' => 'feature', // Custom post type, | |
'post_status' => 'publish', | |
'tax_query' => array( // Taxonomy query parameters | |
array( | |
'taxonomy' => 'feature-category', // Taxonomy name | |
'field' => 'slug', // Field to query (slug, id, name) | |
'terms' => $feature_category, // Term or terms to query | |
), | |
), | |
'posts_per_page' => 99, // Number of posts to fetch | |
'orderby' => array( | |
'menu_order' => 'ASC', // Primary order by menu_order | |
'title' => 'ASC' // Secondary order by post title | |
), | |
] ); | |
$feature_value_key = $feature_category . '-features'; | |
$feature_values = get_post_meta( $post->ID, $feature_value_key, true ); | |
?> | |
<h3><?php echo $term->name ?></h3> | |
<table> | |
<thead> | |
<tr> | |
<th>Feature</th> | |
<th>Groundhogg</th> | |
<th>ActiveCampaign</th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php | |
while ( $feature_query->have_posts() ): | |
$feature_query->the_post(); | |
$feature_slug = get_post()->post_name; | |
// Feature has not been setup in the table yet | |
if ( ! isset( $feature_values[$feature_slug] ) || empty( $feature_values[$feature_slug] ) ){ | |
continue; | |
} | |
?> | |
<tr> | |
<td> | |
<?php echo \Groundhogg\html()->e( 'a', [ | |
'href' => get_permalink( get_the_ID() ), | |
'target' => '_blank' | |
], get_the_title() ) ?> | |
</td> | |
<td>✅</td> | |
<td> | |
<?php echo $feature_values[$feature_slug] ?> | |
</td> | |
</tr><? | |
endwhile; | |
?></tbody> | |
</table><? | |
endforeach; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment