Replace permalink with 'your_acf_field_name' your ACF


 


function my_custom_permalink_filter( $post_link, $post ) {

if ( 'news-articals' === $post->post_type ) { // Target your specific post type name here

$acf_field_value = get_field( 'url', $post->ID ); // Replace 'your_acf_field_name' with your ACF field name

if ( $acf_field_value ) {

$post_link = $acf_field_value; // Replace the tag with the sanitized ACF value

}

}

return $post_link;

}

add_filter( 'post_type_link', 'my_custom_permalink_filter', 10, 2 );

Comments

Popular posts from this blog

Get Post Data From Simple Post custom shortcode

Top 20 Beautiful Pen For Writing

Fatal error: Maximum execution time of 300 seconds exceeded in C:\xampp\phpMyAdmin\libraries\classes\Dbi\DbiMysqli.php on line 199