Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to work with an old plugin http://wordpress.org/extend/plugins/wp-ecards/ (I'm not the plugin author) and I get this error in the php error log and a blank screen when trying to view the e-card on site:

 Failed opening '' for inclusion (include_path='.:/usr/share/php:/usr/share/pear')
 in /home/public_html/demo/wp-content/plugins/wp-ecards/ft-wp-ecards.php on line 171

I don't know what is happening. Is this plugin trying to load the pear library? Any ideas?

The function around line 171 is below (with line 171 marked as such) :

function init_wpecards_viewcard(){
    global $wp_query;
    if ( isset($wp_query->query_vars['ft_wpecards_view']) ){
        if ( $ft_wpecards_parentpost = ft_wpecards_get_post_id($wp_query->query_vars['card']) ){
            if ( ft_wpecards_get_post_type($wp_query->query_vars['card']) == 'post' ) {
                query_posts("p=".$ft_wpecards_parentpost."&ft_wpecards_view=1&card=".$wp_query->query_vars['card']);
                include(get_single_template());  
                //exit;
            }else{


    query_posts("page_id=".$ft_wpecards_parentpost."&ft_wpecards_view=1&card=".$wp_query->query_vars['card']);
                    include(get_page_template()); //LINE 171
                    //exit;
                }
            }else{
                include(get_404_template());
            }
            exit;
        }
        //die('tr');
    }
    add_action('template_redirect','init_wpecards_viewcard');
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Would it not make more sense to use get_template_part() ? What may be happening is that there is no 404 template:

if ( '' != get_query_template( '404' ) )
   include( get_query_template( '404' ) );

http://codex.wordpress.org/Function_Reference/get_query_template

This may be because pretty permalinks have been turned off, or because there is no 404 page template to be found.

The same is true of your get_page_template:

  • You called query_posts but you did not call wp_Reset_query afterwards
  • get_page_template must be called within the post loop, yet there is no post loop to be found
  • you have the ID, it would be far easier to do a get_post_meta($ft_wpecards_parentpost,'_wp_page_template',true); to grab the page template filename, prefixed with the theme folder url
share|improve this answer
    
Thanks, I'm not the original plugin author; I'm just trying to get it to work. I do have a 404 and permalinks are on. The plugin will generate an e-card, but actually viewing the e-card URL is broken. The plugin is wordpress.org/extend/plugins/wp-ecards –  songdogtech Nov 16 '11 at 19:52
    
As I said, include(get_page_template()); needs to be inside the post loop, but you haven't got a post loop, you've left it out, the whole have_posts() the_post() etc? –  Tom J Nowell Nov 16 '11 at 19:57
    
get_page_template() doesn't have to be called within the loop, it actually uses get_queried_object_id() which is accessible very early on. But otherwise, I think Tom is right on. It says "Failed including ''"; which indicates that get_page_template() is returning an empty string, indicating that - most likely - the code is being called somewhere other than on a Page. –  goldenapples Nov 16 '11 at 20:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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