0

as a plus to my question here: Multiple Permalinks for custom post type post

I have an additional question. I make a new question because the old one is answered correctly.

My Code is the following:

function add_my_rule() {
    add_rewrite_rule(
        'test-subject/(\d+)/?',
        'index.php?p=$matches[1]', 'top'
    );
    flush_rewrite_rules();
}
add_action('init', 'add_my_rule');

This code is placed in my index file in my plugin.

The thing is now: We have an meta_key called test_id. So I want to make a link like https://www.example.com/test-subject/1. In this link 1 is not the post id it is the test_id from the meta_key of a post. So I want to redirect to the post, which have the right meta_key test_id. Some suggestions?

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.