Support

Account

Forum Replies Created

  • I hear you, but Product Type, Season, and Brand are all attributes whereby you filter a product. So you can create a page for Product Type by creating a template that pulls all of the possible values for a given attribute and generating a div for each. When you click through to one of the Product Types, you display a page of Product posts that is filtered by that Product Type. Then you can have, say, a sidebar that displays all the other attributes you can filter by (like Seasons). Something like the way Amazon presents its products. You have to visualize this as a relational database and imagine the data structures and their hierarchies.

  • You need to capture the current ID outside of the loop, otherwise get_the_id() will grab the ID of the post it is currently querying.

    Try moving that chunk of code before the while, e.g.:

    <?php
      if ( is_singular( 'playlists' ) ):
        $current_category = get_field( 'categorias', get_the_ID() );
        if ( have_posts() ):
    ?>
  • Not sure if this is best practice, but it seems to me that it would work to simply query post_type = playlists, as you are doing, but without the meta_query. Instead, inside the loop, include:

    $currentCat = get_field('categorias', $current_id);
    if (get_field('categorias') == $currentCat) {...}

    where the $current_id is captured outside the loop.

  • I assume by “blank space” you’re referring to the line break (<br />). Easy fix. Just include the break inside the if so that it will only render if the field is not null.

    Example:

    <?php
      if (get_field('apelativo')) {
        _e('Apelativo: ','csc-themewp: '); the_field('apelativo');
        echo '<br />';
      }
    ?>
  • Seems to me that you only need one custom post type — Tires (products). Then for this post type, create a custom field group that includes select fields for ‘Product Type’, ‘Season’, and ‘Brand’. Then you can just include some post filtering in your template files for the archive page (which is effectively a complete product list in this scenario).

  • Figured it out after hours in the WP codex. I’m sure this little nugget was buried somewhere in the ACF docs, too.
    With custom post types, you have to enable support for custom fields in the register_post_type() function with the help of the supports parameter, which must include the value custom-fields.
    Magic.

Viewing 6 posts - 1 through 6 (of 6 total)