• To modify the size of videos according to where they are displayed, I am using this in functions.php (the trick was shown to me by the Viper plugin’s author) :

    function frmars_vvq_modifier( $atts, $tag, $rawatts ) {
        if ( in_category('6') ) {
        $atts['width'] = 300;
        $atts['height'] = 233;
      }

    I’ve used this repeatedly and it works very well with :

    if ( is_singular() ) {
        $atts['width'] = 560;
        $atts['height'] = 420;
      }
    
       if ( is_page() ) {
        $atts['width'] = 560;
        $atts['height'] = 420;
      }

    But it does not work with
    • if ( is_page_template() )

    Is this function broken ?
    Am I using it the wrong way ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Well depends on where you are applying the test. It will only work on ‘pages’ not posts. I know that’s obvious but it won’t work on anything other than a page.

    Looking at the function code in the core:

    http://core.trac.wordpress.org/browser/tags/3.0.1/wp-includes/post-template.php

    It seems pretty straight forward, just checks to see if it is a page that you are on first of all, then checks what page template has been set to (on the page edit screen). It returns true if it finds a valid age template assigned to that page (you are currently on), or false otherwise.

    echo out the return value and add the code for is_page_template() to posts (yes posts to prove to yourself it always returns false for posts), and several pages (using all the different types of page template your theme supports). See what it throws out on the screen when you view the posts/pages.

    Thread Starter frmars

    (@frmars)

    Ok then.

    It is a page. But I display posts in this page.
    So it’s a “post in a page”…

    That must explain why.

    Damn ! And thanks for the tip.

    Your function is not doing return $atts; at the end of the function.

    EDIT: Oh, nevermind. It was only a partial paste.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘is_page_template not working ?’ is closed to new replies.