Skip Navigation

[Resolved] Split: Feature request – extend [wpv-archive-title] shortcode to accept the arguments

This support ticket is created 5 years, 4 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by Beda 5 years, 4 months ago.

Assisted by: Beda.

Author
Posts
#1165331

This is definitely helpful, thank you!
However, I wonder if your [wpv-archive-title] shortcode could be modified to take some arguments? Obviously, you already make calls to existing WordPress functions, so this should not be a problem for you from a development standpoint.
I think that your short code could pretty easily be implemented in much the same way that you have done here, except that you should provide an additional argument, $prefix, which defaults to the empty string. Thus your shortcode could be implemented something like this:

function wpv_archive_title( $prefix = null ) {
    // Preserve your current default behavior
    if ($prefix == null || strlen($prefix ==0) {
       $title = get_the_archive_title();
    }
    else {  
      if ( is_category() ) {
          $title = $prefix . single_cat_title( '', false );
      } elseif ( is_tag() ) {
          $title = $prefix . single_tag_title( '', false );
      } elseif ( is_author() ) {
          $title = $prefix . '<span class="vcard">' . get_the_author() . '</span>';
      } elseif ( is_post_type_archive() ) {
          $title = $prefix . post_type_archive_title( '', false );
      } elseif ( is_tax() ) {
          $title = $prefix . single_term_title( '', false );
      }
    }
    return $title;
}

Would you please forward this to the development team as a feature request?
Thank you.
David McLeod

#1165416

I apologise, but I need more details to this.

Am I correct that you want to output the archive title with Toolset, which will always display "Taxonomy_Name Archives: Term_Name", without the String "Archives:"?

So for example, you want to customize (or remove) "Category" in:
Category Archives: Uncategorized

I have seen others asking to remove the word "archive", and even others to choose to display the Term ID, or slug, instead of its name.
Those are all valid requests.

Would you agree upon:
- provide a method to alter the prefix of the *Category Archives: Uncategorized* string
- provide a method to alter what to output for the Taxonomy (Slug, ID, Name)
- provide a method to alter what to output for the Term (Slug, ID, Name)
- provide method to alter string "Archives:"

#1165633

When you invoke get_the_archive_title(), you get back something like the following...
"Category: <Some Category>"
"Tag: <Some Tag>"
"Author: <Some Author>"

However, the different method calls in the code above just return the substrings "<Some Category>", "<Some Tag>", "<Some Author>", etc. That is, the same archive title WITHOUT the prefix.

I'm recommending that you modify the [wpv-archive-title] shortcode to make the prefix optional (or to change it to something else. Incorporating the other ideas you list at the bottom of your message suggests to me a shortcode of the following structure:

[wpv-archive-title prefix="Optional Prefix" taxonomy="slug | id | name" term="slug | id | name"]

All options are nullable, defaulting to the current behavior (which ensures that any existing usages of [wpv-archive-title] will still work. The implementation would be something similar to what I've provided above, although you may have additional use-cases to consider.

I hope this answers your question.

David McLeod

#1166186

Great, thanks.

I have filed it here for the records https://toolset.com/feature-request/extend-the-views-archive-title-shortcode-so-to-customize-the-output/, however likely this system soon changes and the list might disappear, there is hence no hurry in voting it up either.

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