How add any custom text as Suffix OR Prefix in post url: WordPress


Hello Friends! 🙂

If you want to add any text in Post URL (suffix/prefix) then just use my code

function save_url_suffix($post_id) {
global $meta_box;

// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check permissions
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}

global $wpdb;
$myrows = $wpdb->get_results( "SELECT post_name from  wp_posts WHERE ID ='$post_id' AND post_status = 'publish'" );
//print_r($myrows);
    foreach ($myrows as $page) {
            //echo $page->post_name.'<br/>';

       $wpdb->query("UPDATE ".$wpdb->posts." SET post_name ='".$page->post_name."_".$post_id."'  WHERE ID ='".$post_id."'");
      //add_action( 'save_post', 'save_seo_meta_box' );   
 }

}

Enjoy Code! | Raghunath Blog 🙂 🙂

Advertisements

Sr. Software Engineer

Tagged with: , , ,
Posted in Wordpress
11 comments on “How add any custom text as Suffix OR Prefix in post url: WordPress
  1. opis says:

    Fenomenala ocena. Właśnie takiej informacji szukałem. Wyślę tę witrynę
    przyjaciołom. Przyrzekam że będę tu wracał. Szczęścia
    w dalszym tworzeniu.

  2. Jack says:

    Hey I қnow this is off topic bսt I waѕ wondering if
    уοu knew of any widgets I could add tο my blog that automatically tweet mү nеwest twitter updates.
    I’ve been looking fоr a plug-іn likе this for quite sоme time aոd
    աas hoping maybe үou ѡould havе ѕome experience ԝith ѕomething like this.
    Plеase let me know if yoս ruո into anything. I tгuly enjoy reading
    ƴour blog and I look forward tо yoսr ոew updates.

  3. Nichole says:

    First off I want to say awesome blog! I had a quick question which I’d like to ask if you do not
    mind. I was interested to find out how you center yourself and clear your mind prior to writing.
    I’ve had trouble clearing my thoughts in getting
    my thoughts out. I do take pleasure in writing but it just seems like the first 10 to
    15 minutes are usually wasted just trying to figure out how
    to begin. Any ideas or tips? Thank you!

  4. Eedwin says:

    What’s up to every one, it’s actually a fastidious for me to visit this web page, it includes important Information.

  5. Have you ever considered about including a little bit more than just your articles?
    I mean, what you say is valuable and everything. However think about if you added some great visuals or video clips to give your
    posts more, “pop”! Your content is excellent but with pics and videos,
    this site could definitely be one of the best in its field.
    Wonderful blog!

  6. Robbin says:

    Awesome site you have here but I was curious if you knew of any message boards
    that cover the same topics talked about in this
    article? I’d really love to be a part of community where I can get comments
    from other experienced people that share the same interest.
    If you have any suggestions, please let me know.

    Cheers!

  7. Monserrate says:

    Hello! I could have sworn I’ve been to your blog before but after
    looking at many of the articles I realized it’s new to me.
    Anyhow, I’m definitely pleased I discovered it
    and I’ll be bookmarking it and checking back often!

  8. Vanita says:

    If you wish for to obtain a great deal from this
    article then you have to apply such methods
    to your won webpage.

  9. Nice Blog, thanks for sharing this kind of information.

  10. Marc says:

    which file i have to modify?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: