Skip Navigation

[Resolved] Creating an archive that use custom archive fields

This support ticket is created 3 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by markH-29 3 years ago.

Assisted by: Waqar.

Author
Posts
#2003907
Screen Shot 2021-03-28 at 11.03.57 PM.png

I'm in the process of converting an existing food-related site from Divi to a site that uses Toolset with a Kadence theme. The site has tons of content but is in need of reorganization.

What I'm stuck on is creating archives for taxonomies that use custom fields. I've created a number of custom taxonomies (cuisine, ingredient, etc) and assigned them to our standard post. I'm able to use the taxonomies with our existing posts and to use the taxonomies to filter the related post views that show up at the bottom of our regular posts.

I also added a number of custom fields, using a field group, to the taxonomies. The custom fields include a featured image, image field, subheading, and content field for longer descriptions of the categories. What I'm trying to do is design custom taxonomy archives that display info about the term and some images before displaying posts for that term as a way to boost our SEO. I thought about creating custom post types to make it easier to display more info but I thought it would be harder to connect everything on the back end.

However, when I create a custom archive for a taxonomy I'm unable to access the custom fields that I've added to the taxonomy. An example is located at hidden link (it's a staging site, so you'll need to enter dev in the popup for user and password to see the site.

For this archive I'm only able to add the title of the posts that are using that category, using the current post field. I'm unable to access any of the custom fields or the custom field group through the more settings on the right hand side of the edit menu or the field and views field. I can't even get the category to display the title of the category on the page.

I've gone through almost all of the training materials on the site related to custom fields and haven't been able to figure out what I'm doing wrong. I'm not sure if there's a setting or if I need to do something different for taxonomies than when I'm creating archives for custom posts - almost all of the training material for custom fields shows how they're used for custom posts and I haven't been able to find a lesson that creates a custom archive for a taxonomy showing all of the steps, let along one that adds in custom fields.

Anyways, I'm stuck and could use some help.

Thanks, Mark

#2003943

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Mark,

Welcome to Toolset support and I'd be happy to assist.

Your observation is correct and currently there is no built-in feature available to show the taxonomy term custom fields data on the custom archive pages.

We have an internal ticket to introduce this in future releases, and for now, a workaround can be to register a custom shortcode for this:


add_shortcode( 'taxonomy', function( $atts ){
 
    global $wp_query;
    $tax = $wp_query->get_queried_object();
 
    if ( isset( $atts['field'] ) ) {
        $content = get_term_meta( $tax->term_id, $atts['field'], true );
    } else {
        $content = "";
    }
 
    return $content;
});

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

After that, you can use this new shortcode in your archives, through a "Fields and Text" block like this:


[taxonomy field="wpcf-term-field-slug"]

Note: Please replace "term-field-slug" with your actual term custom field's slug.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2012715

Thanks,

This was somewhat helpful. I was able to add the code and can use the shortcode feature to add simple single fields to the category pages, such as the subheading, but I'm not able to use it for images or complex text fields. I've tried both single images and galleries, which is how I would like the final category pages to be.

I can get it to show the URL link to the featured image but not the image itself. You can see an example here hidden link. To access the staging site just enter dev into the user name and password fields that pop up when you go to the site.

I was unable to get the multiline field I had created for the category description to show up, so I switched over to the built-in description field, which works ok, but it doesn't allow me to add images to it and forces me to use this field differently then I had planned.

Any help you can provide to being able to use these features would be great. Building out the look and description of our category pages is key to our SEO strategy, so this is a pretty big deal for us.

Also, any idea when the features you mention in your first email will be available?

Thanks,

Mark

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.