基于自定义字段过滤器获取存档的URL链接


Wordpress: Getting URL link for archive based on custom field filter

我正在尝试提供一个链接在一个wordpress帖子,将导致用户到存档视图与其他帖子具有相同的自定义字段。

换句话说,很像get_author_posts_url,但是get_customfield_posts_url

提前感谢!

Wordpress不提供此功能,您需要编写此功能。

/*
    This will be your home work:
    1. You need a page with a custom template
       + query var that returns the value of the custom field
       + custom loop that (you may use meta_query) finds posts
         with the same custom field value
    2. make function to convert the custom field
       to a custom permalink may be.
    http://example.tld/my_page/?custom_field=custom_field_value