MrFent37,
The plugin cannot do that, unfortunately. That said, since you are proficient enough to create a shortcode, I will tell you how I would go about doing something like this (if it were me).
- Create a page called ‘Weekly Schedule’ or something similar.
- Add a custom field to that page, say ‘
schedule-url
‘ and have the value be the URL pattern you want to use – in this case, something like ‘http://www.hayhouseradio.com/#!/schedule-by-day/[schedule-url]
‘.
- In the
functions.php
file (where you would have added your shortcode) add the following (after the <?php
):
add_action('template_redirect', 'override_schedule_link_custom', 5);
function override_schedule_link_custom(){
global $post;
if( is_admin() || is_404() || !is_singular() || !isset( $post->ID ) )
return;
$link = get_post_meta( $post->ID, 'schedule-url', true );
if( $link != '' ){
$redirect_link = str_replace( '[schedule-url]' , date( "Y-m-d", strtotime( "this Tuesday" ) ) , $link );
wp_redirect( $redirect_link, 302 );
exit;
}
}
- This will redirect if the post has the custom field called
schedule-url
(does not matter the page or the post, as long as it has that custom field).
Then when anyone goes to http://yoursitehere.com/weekly-schedule/
, they will always get redirected to the that same URL you posted in your page. You could put the link in any page or anywhere on the web and it will work. You could even throw this code in a plugin and use it that way too.
Disclaimer – I typed this off the top of my head, on-the-fly, so there could be errors – but is should point you in the correct direction if it does not work out of the box.
Best of luck,
Don
Thanks Don! I decided to just go with a custom wp_redirect(); function instead
Hello MrFent37,
Could you post your code of how you accomplished this? I’m also looking to put shortcode into the url.
Thanks!
zdavis, I didn’t actually use my shortcode, nor did I even use this plugin to accomplish what I needed to do. I just created a custom redirect function, and applied it to the one specific page that I needed to dynamically redirect to. Here’s my code:
function hayhouse_radio_page() {
$hayhouseradio = sprintf('http://www.hayhouseradio.com/#!/schedule-by-day/%s', date("Y-m-d", strtotime("this Tuesday")));
if (is_page(57476)) {
wp_redirect($hayhouseradio);
exit;
}
}
add_action('template_redirect','hayhouse_radio_page');