Home › Forums › Jevelin Theme › Blog Template
Home › Forums › Jevelin Theme › Blog Template
Inside of the blog template page in the theme /page-blog.php there seems to be a bug for both the category listing and the blog listing details, for the category listing I had to rework the ternary operator so it would list the categories correctly and for the category filters i had to rework this because the category names were being concatenated into one long string and breaking the page. i am slightly concerned with this because i have modified the theme files directly and do not want my work to be erased in future updates, please advise. For reference the changes are prefixed with comments.
<div>
<div>/////////////////////////////////////</div>
<div> // fix category check</div>
<div> //Fix: Check if category exists and either has posts or you want to show empty categories</div>
<div> /*if( !empty( $category->count ) && $category->count > 0 ) : ?>*/</div>
<div> if( $category && !is_wp_error( $category ) && ( $category->count > 0 || true ) ) : ?></div>
</div>
<div></div>
<div></div>
<div>
<div>
<div>////////////////////////////////////////////////</div>
<div> //Updated Section to fix category filter issue</div>
<div> /*</div>
<div> The debug output shows that the category filter is concatenating all the category names into one long string: “Day 1Day 2Day 3Day 4Day 5Day 6Day 7Day 8Day 9Day 10Day 11Day 12” instead of treating them as separate categories.</div>
<div> the problem is in the category handling logic. When using category_name in WP_Query, it expects category slugs separated by commas, not names concatenated together.</div>
<div> */</div>
<div> // if( $cat_att == ‘category_name’ && is_array( $cat_var ) ) :</div>
<div> // $cat_var = implode( ‘,’, $cat_var );</div>
<div> // endif;</div>
<div> if( $cat_att == ‘category_name’ && is_array( $cat_var ) ) :</div>
<div> // Fix: Convert category IDs to slugs and join with commas</div>
<div> $category_slugs = array();</div>
<div> foreach( $cat_var as $cat_id ) {</div>
<div> $category = get_term_by( ‘id’, $cat_id, ‘category’ );</div>
<div> if( $category ) {</div>
<div> $category_slugs[] = $category->slug;</div>
<div> }</div>
<div> }</div>
<div> $cat_var = implode( ‘,’, $category_slugs );</div>
<div> endif;</div>
<div> /* End fix */</div>
</div>
</div>