8

I am trying to alter the default "preview post" button when posting on wordpress as the site has a hacked wordpress install and the posts previews are not where they are suppose to be.

I found the hook preview_post_link now I am just trying to figure out how to make a little plugin that will fix the problem.

What I don't know how to do and why I am posting here is, using the add_filter to change the link

add_filter( 'preview_post_link', 'the_preview_fix' );

function the_preview_fix() {

    return;
}

all I need it to do is instead of going to its current link go to www.website.com/blog/p/the-slug as even though the draft post doesn't appear on the live site the link will still take me to a generated page :)

Thanks in advance for any and all help received

EDIT FIXED IT!

add_filter( 'preview_post_link', 'the_preview_fix' );

function the_preview_fix() {
    $slug = basename(get_permalink());
    return "http://www.mywebsite.com/blog/p/$slug";
}
3
  • Post your fix as an answer and accept it so others will see that the question has been answered, even if you answered it yourself :)
    – JimmyPena
    Jan 5, 2012 at 17:03
  • Don't have enough rep to do that yet :( Jan 6, 2012 at 14:29
  • Really? I understand you might not be able to accept your own answer, but you can't even answer questions period?
    – JimmyPena
    Jan 6, 2012 at 16:34

1 Answer 1

9
add_filter( 'preview_post_link', 'the_preview_fix' );

function the_preview_fix() {
    $slug = basename(get_permalink());
    return "http://www.mywebsite.com/blog/p/$slug";
}
2
  • May I ask: Where did you put the code that fixed your problem? I'm in the same boat and unfamiliar with WP. TIA! Aug 3, 2014 at 12:23
  • 1
    Found the answer: the code above needed to be appended to the functions.php file in my theme. Aug 6, 2014 at 15:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.