Skip Navigation

[Resolved] Dynamic views?

This support ticket is created 5 years, 9 months 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 21 replies, has 2 voices.

Last updated by Bonnie 5 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#1196604

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

(Quick update to say it happens without Types, it is what I would describe as an unexpected quirk of WordPress.)

#1196605

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Sorry, just saw your question.

The current archive format is determined by your theme.

You can customise what is output for each post returned by the archive by creating a custom archive at Toolset > WordPress Archives.

It is very much like creating a View, which you have done already, so should be familiar, but let me know if you are stuck.

#1196697

Thanks, Nigel.

I've managed to create this at hidden link

Quick question...

<h2>[wpv-archive-title]</h2>

This shows A-Z: A but I'd like it just to say "A". Any ideas for how to do this?

#1196779

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

What you need is to output the term name, and we don't have a shortcode for that which works in this context.

You can register a custom shortcode that will; here is a general purpose one you can use:

/**
 * Register shortcode to output current taxonomy
 * for use on taxonomy archive page outside or inside loop
 * att['output'] string taxonomy | name (default) | slug | term_id | description | count | field (requres att['field'])
 * att['field'] string key
 */
add_shortcode('taxonomy', function ($atts = [], $content = null) {
 
    // provide defaults
    $atts = shortcode_atts(
        array(
            'output' => 'name',
            'field' => '',
        ),
        $atts
    );
    extract($atts);
 
    $return = '';
 
    global $wp_query;
    $obj = $wp_query->get_queried_object();
 
    if ($output != 'field') {
 
        $return = $obj->$output;
    } else {
        if (isset($field)) {
            $return = get_term_meta($obj->term_id, $field, true);
        }
    }
 
    return $return;
});

Add that as a code snippet at Toolset > Settings > Custom Code.

To output the term name use the taxonomy shortcode on its own without arguments, but for reference you can also use it like

[taxonomy output='taxonomy'] -- outputs the taxonomy slug
[taxonomy] -- outputs the term name (default)
[taxonomy output='count'] -- outputs the count of results
[taxonomy output='field' field='wpcf-colour'] -- outputs a 'colour' taxonomy custom field
#1197109

This is perfect and has worked brilliantly - thanks so much! ? I have also learnt about the "custom shortcodes" feature which I had no idea existed.

Finally, before I leave you alone, can I ask how I can use Views to get rid of the search box at the bottom and the title "Archives" at the top of the page e.g. here: hidden link

#1197292

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I don't think Views can help you here.

Any WordPress page is generated by a theme PHP template, so that page might be generated by an archive.php file, for example.

The only part of the page which Toolset replaces is the part which is output by the function the_content() in the theme file, effectively the post body of what's being displayed. Everything outside of that is output by the theme.

That would be the case with these elements you want to remove.

You would need to make a duplicate of the theme PHP template (e.g. archive.php) and add that to a child theme, where you can safely edit it, removing the parts that you do not want.

But, as I say, it is outside of Toolset's realm.

#1197388

Thanks, Nigel. 🙂