Need some guidance.
-
Hi, I am using Simple Urls to setup redirects on my blog. I am trying to achieve auto posting of Simple URLS post on publishing a blog post. For example, If i publish a post about StudioPress it will be automatically publish a redirect with Title similar to blog post. i.e StudioPress.
Now i am using a custom field URL that i want to put in the Redirect URL of Simple URL.
In simple terms, i want to clone blog post for surl post type with similar title and for redirect url i will setup a Custom Field Named “URL”.
I am somehow successful in cloning the post title but the redirect url is not copying. Here is my code. Please have a look and correct the error for Custom Field URL.
add_action( 'save_post', 'save_postdata_wpse_76945', 10, 2 ); function save_postdata_wpse_76945( $post_id, $post_object ) { // Auto save? if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; // Correct post_type if ( 'post' != $post_object->post_type ) return; // Security if ( !isset($_POST['noncename_wpse_76945']) || !wp_verify_nonce( $_POST['noncename_wpse_76945'], plugin_basename( __FILE__ ) ) ) return; // Prepare contents $add_cpt_clone = array( 'post_title' => $post_object->post_title, '_surl_redirect' => get_post_meta( get_the_ID(), 'url' ), 'post_status' => 'publish', 'post_type' => 'surl' ); // Insert the post into the database $p_id = wp_insert_post( $add_cpt_clone ); // Use $p_id to insert new terms }
I know i am doing some mistake here
'_surl_redirect' => get_post_meta( get_the_ID(), 'url' ),
But i don’t know how to correct it. I am using ACF for generating custom field URL.
Any Ideas. It’s very urgent and i am using Genesis and therefore, i don’t want to use any other plugin that is not done by Genesis team. Regards
- The topic ‘Need some guidance.’ is closed to new replies.