דלג על ניווט
Sun Mon Tue Wed Thu Fri Sat
12:00 – 20:00 12:00 – 20:00 12:00 – 20:00 12:00 – 20:00 12:00 – 20:00 - -
- - - - - - -

אזור זמן של תומך: Asia/Karachi (GMT+05:00)

תגיות: 

נושא זה מכיל 0 תגובות, יש ל 1קוֹל.

עודכן לאחרונה על ידי jamesB-70 לפני יום 1, 20 שעות.

בסיוע: Noman.

מחבר פוסטים
פברואר 27, 2025בְּ- 1:26 pm #16756299

jamesB-70

Background of the issue:
I am trying to get /post/ between locale and post name in URL. Here is a code:

function custom_post_permalink_structure($permalink, $post, $leavename) {
if ($post->post_type == 'post') {
$permalink = home_url('/post/' . $post->post_name);
}

return $permalink;
}

add_filter('post_link', 'custom_post_permalink_structure', 10, 3);
add_filter('post_type_link', 'custom_post_permalink_structure', 10, 3);

function custom_post_rewrite_rule() {
add_rewrite_rule('^post/([^/]+)/?', 'index.php?post_type=post&name=$matches[1]', 'top');
}

add_action('init', 'custom_post_rewrite_rule');

Link to a page where the issue can be seen: קישור נסתר

Symptoms:
After adding translation to the post, WPML switcher is broken for this post.

Questions:
How can I ensure the correct URLs with /post/ and correct lang slug in the language switcher?
What is the correct solution compatible with WPML for this issue?

הנושא '[סגור] Can't correct add /post/ before post slug ' סגור לתשובות חדשות.