WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Multiple Tags Pages (7 posts)

  1. Clicknathan
    Member
    Posted 6 years ago #

    I'm wondering if there's a URL string that can represent multiple tags.

    Something like:

    website.com/?tag=cigarettes&addiction

    This doesn't work, it only returns the cigarettes tag result.

    Any ideas?

  2. Kafkaesqui

    Posted 6 years ago #

    ?tag=cigarettes,addiction

    returns posts with the tags cigarettes OR addiction

    ?tag=cigarettes+addiction

    returns posts with the tags cigarettes AND addiction

  3. Clicknathan
    Member
    Posted 6 years ago #

    Thanks Kaf. I had tried all combinations of ampersands, some slash combos.

    Good ol' commas and plus signs. In this day and age of space pirates and Wii remotes how often we forget the simple things.

  4. 11Mystics
    Member
    Posted 6 years ago #

    Thanks for this tip - exactly what I needed too, but now I have another problem related to this.

    I display wp_title() on all my pages which works great and looks really nice. But when you generate a page with two tags, the title only shows the first tag specified and NOT the second one. It's creates a misleading visual.

    I found a php tag for single tag title, but no multiple tag title. Is there any way to do this?

  5. &'s are reserved for splitting up parameters. In your original code, tag is set to cigarettes and addiction is set, but blank. ;)

  6. scribblerguy
    Member
    Posted 6 years ago #

    This is for 11Mystics (and anyone else curious). The following is how I'm currently grabbing the tag query string for display purposes. Inside my functions.php file is the following:

    function my_get_the_tag_query() {
     $nice_tag_query = $_SERVER['REQUEST_URI'];
     $nice_tag_query = str_replace('/tag/','', $nice_tag_query);
     $nice_tag_query = str_replace(',', ', ', $nice_tag_query);
     $nice_tag_query = str_replace('/','', $nice_tag_query);
     return $nice_tag_query;
    }

    Quick explanation: The above assumes a permalink structure where the base for all tag pages is "/tag/" (e.g. "www.example.com/tag/"). The function grabs part of the URL/URI string and then uses the str_replace() function to clean up the output by removing the "tag" and slashes. Right now, I'm leaving the plus signs as is and just adding a space after any comma.

    For the web page title, just echo the output of this function. If you're using a common header file, then add an extra conditional statement for the title section, using WordPress' is_tag() function.

  7. gmcpress
    Member
    Posted 6 years ago #

    I wanted to check with all of you to see if there is a way to do the following:

    I am providing space for users to add tags to individual posts, and I wanted to database/track every tag entered, even the duplicates, then report back tag counts for each post in multiple formats (list/array/cloud/etc.)

    Am I better trying to do this with Keywords? How do you do it with the database? And could you still click (or sort) by tags/keywords to deliver all of the posts that share a specific tag, or tag that has been assigned a specific number of times?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic