This particular website is using Tubepress to display a youtube video gallery. Now, Tubepress recommends that, to define which video goes to the front part of the gallery, we should append the id to the url, like this:


So, i already have a an option stored with the default video ID for the videos page, but i'm getting some trouble in dinamically appending that value to the URL everytime the video page is loaded.

So far, i've tried URL Rewrites, with no luck, and then i found this: Custom URl parameter and it seemed to be exactly what i want. I figured there's also a page_link filter hook, but there's no documentation on it. So this still isn't working and i'm not quite sure why.

Me actual code looks like this:

function append_parameter( $link, $my_parameter ) {

    if(is_page('videos')) {
        $my_parameter = get_option('featured_video_id');

        if ( isset($my_parameter) ) { 
            $link = add_query_arg( 'tubepress_video', $my_parameter );
        return $link;
add_filter( 'page_link','append_parameter', 10, 2 );

any ideas?

1 Answer 1


In the example you link this is how the parameter is added:

add_query_arg( 'sort', $my_parameter, $link );

However, in your example you missed the link parameter.

Does it work if you replace it with:

$link = add_query_arg( 'tubepress_video', $my_parameter, $link );


  • Not really. The last parameter is optional and defaults to $_SERVER[];
    – moraleida
    Commented Mar 30, 2012 at 12:46
  • @moraleida True, but that is not really what you want. I tried it and it works for me with added $link parameter. Is your video page actually a Wordpress page? If it is not, this will not work. The documentation for page_link and other link-filter can be found here
    – tim
    Commented Mar 30, 2012 at 13:03
  • The video page is a wp page, up and running. And i got $link back and now i get the correct query. But i guess this hook isn't what i thought, then. I wanted a hook that would redirect any links to mysite.com/videos/ to mysite.com/videos/?tubepress_video=somevideoid, so appending values before page load...
    – moraleida
    Commented Mar 30, 2012 at 13:18
  • 1
    I am not quite sure what you mean by "appending values before page load", but I think that the parameter is not displayed in the links to the page itself, but added right before/at the time the link is called? I do not think that wordpress supports that, but you could either just set the get parameter yourself by adding $_GET["tubepress_video"] = get_option('featured_video_id'); at the beginning of video.php or - if somevideoid is fixed - use the servers rewrite engine. Both are not great ways, but I do not think that there really are better alternatives.
    – tim
    Commented Mar 30, 2012 at 13:45
  • $_GET["tubepress_video"] = get_option('featured_video_id'); worked perfectly. Sometimes i just hate the fact that i know more about wordpress than about PHP itself. Thanks!
    – moraleida
    Commented Mar 30, 2012 at 13:54

Your Answer

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

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