WordPress.org

Ready to get started?Download WordPress

Forums

Build custom permalinks tags (1 post)

  1. grosbouff
    Member
    Posted 4 years ago #

    Hi, is it possible to build custom permalink tags and use them ?

    Example :

    Currently I have the current permalink for my single post :

    .../%year%/%monthnum%/%category%/%postname%/
    giving
    .../2009/11/dogs/wondeful-shihuahua/

    Hi would like to

    ADD A CUSTOM PERMALINK TAG defined with a function.
    Let's say the tag name would be "action"

    The permalink would be

    .../%year%/%monthnum%/%action%/%category%/%postname%/

    And the %action% value would be build with a function that checks something.

    It that case, I would like action to be "sell" if the single post contains the "sell" tag, and the action to be "buy" if the single posts contains the "buy" tag. Else, nothing.

    Something like

    function get_permalink_action_tag():
    global $post:

    $post_tags = wp_get_post_tags($post->ID);
    if ($post_tags) {
    foreach($post_tags as $tag) {
    if (($tag=='sell') || ($tag=='buy'))
    return $tag;
    }
    }

    Is it possible ?

    Thanks !

Topic Closed

This topic has been closed to new replies.

About this Topic