Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving trouble with wordpress's add_filter for preview_post_link
    text
    copied!<p>So at my new job, I'm working with a slightly customized version of wordpress, where the front end is run by Java, the backend via wordpress. They have a bunch of manually added "plugins", which are really just php function files.</p> <p>I need to redirect the post preview link to the appropriate front end page, and am having trouble doing so. Through some googling and stack overflow, I found this solution:</p> <pre><code>add_filter('preview_post_link', 'falcon_preview_link', 50); add_filter('preview_page_link', 'falcon_preview_link', 50); function falcon_preview_link($link) { error_log('falcon preview redirect'); $slug = basename(get_permalink()); return "http://www.mywebsite.com/blog/p/$slug"; } </code></pre> <p>Obviously the contents of the function will be changed.</p> <p>The issue is, as far as I can tell, the preview link doesn't change. I never see the text 'falcon preview redirect' in my error log. I've tested to see if the page gets loaded, which it does (error log at the bottom of the page), and if I call the function directly if it works, which it does. So I know the page is getting included and the function doesn't break down entirely, but when I go to a post page, the link is set to the default wordpress preview link and not the random stuff I've been putting in to test. I bumped the priority up to 50 just in case something else was overwriting it.</p> <p>Does anyone have any ideas on where I'm going wrong or advice on how i can figure out the issue?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload