2014-06-26 112 views
1

我的公司有一個自定義WordPress網站創建,當我們試圖加載到WAMP服務器,頁面不加載。相反,我們得到的是實際的頁面代碼和錯誤,這是讓我的老闆撓頭,我想看看我能不能找人來幫助我們,並找出爲什麼不能正確加載。任何人都可以瞭解我們爲什麼會收到以下問題。自定義Wordpress網站加載錯誤

我們得到以下錯誤:

Query is not defined 

jQuery(function(){ 

而且我們越來越像一串代碼和jibberish如下:

__('Header Menu'), 'footer-menu' => __('Footer Menu'))); } add_action('init', 'register_my_menus'); add_theme_support('post-thumbnails'); add_image_size('home-header', 1920, 550); //home header image add_image_size('home-short-story', 303, 363); // home short story image add_image_size('news-article-sidebar-thumbnail', 90, 90, true); //sidebar news add_image_size('sidebar-promo-box-image', 125, 100, true); // blue custom sidebar widget image add_image_size('program-image', 221, 197, true); //program listing add_image_size('program-type-image', 372, 221, true); // /programs view add_image_size('directors-headshot', 194, 230, true); //directors image of directors add_image_size('news-article-listing-image', 194, 230, true); add_image_size('staff-headshot', 104, 120, true); // images of staff add_image_size('footer-logos', 60, 60); // footer logos add_image_size('page-header', 1920, 199, true); // header for page add_image_size('google-maps', 302, 138); // contact us sidebar google maps image add_action('init', 'create_post_type'); function formatDate($startingDate,$endingDate,$startingTime,$endingTime,$shorter=false){ $return=''; $month=($shorter) ? 'M' : 'F'; $start_d = mysql2date('j', $startingDate); $end_d = mysql2date('j', $endingDate); $start_m = mysql2date('m', $startingDate); $end_m = mysql2date('m', $endingDate); if($start_m == $end_m){ if($start_d == $end_d){ $return.=mysql2date($month.' j, Y', $startingDate); }else{ $return.=mysql2date($month.' j', $startingDate); $return.=mysql2date(' - j, Y', $endingDate); } } else{ $return.=mysql2date($month.' j', $startingDate); $return.=mysql2date(' - '.$month.' j, Y', $endingDate); } if($startingTime){ $return.=' ('.$startingTime; if($endingTime){ $return.=' - '.$endingTime; } $return.=')'; } return $return; } function create_post_type() { /*if (!post_type_exists('news-and-research')) { register_post_type('news-and-research', array('labels' => array('name' => __('News & Research'), 'singular_name' => __('News & Research')), 'public' => true, 'has_archive' => false, 'hierarchical' => true, 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'page-attributes', 'comments'))); }*/ if (!post_type_exists('quotes')) { register_post_type('quotes', array('labels' => array('name' => __('Quotes'), 'singular_name' => __('Quotes')), 'public' => true, 'has_archive' => false, 'hierarchical' => true, 'supports' => array('title', 'editor', 'page-attributes'))); } if (!post_type_exists('programs')) { register_post_type('programs', array('labels' => array('name' => __('Programs'), 'singular_name' => __('Programs')), 'public' => true, 'has_archive' => false, 'hierarchical' => true, 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'page-attributes'))); } if (!post_type_exists('lodging-template')) { register_post_type('lodging-template', array('labels' => array('name' => __('Lodging Templates'), 'singular_name' => __('Lodging Template')), 'public' => true, 'has_archive' => false, 'hierarchical' => true, 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'page-attributes'))); } if (!post_type_exists('activities-template')) { register_post_type('activities-template', array('labels' => array('name' => __('Activities Templates'), 'singular_name' => __('Activity Template')), 'public' => true, 'has_archive' => false, 'hierarchical' => true, 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'page-attributes'))); } if (!post_type_exists('application-template')) { register_post_type('application-template', array('labels' => array('name' => __('Application Templates'), 'singular_name' => __('Application Template')), 'public' => true, 'has_archive' => false, 'hierarchical' => true, 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'page-attributes'))); } flush_rewrite_rules(false); } //use parent template (Propose a program, People) function set_page_template_to_parent() { global $post; if (is_page()) { if ($post->post_parent == 0) return true; else if (($post->post_parent != $post->ID) && ($post->post_parent==64 || $post->post_parent==97)) { $parent_page_template = get_post_meta($post->post_parent,'_wp_page_template',true); $template = TEMPLATEPATH . "/{$parent_page_template}"; if (file_exists($template)) { load_template($template); exit; } } } } add_action('template_redirect','set_page_template_to_parent'); function build_menu($menu_name) { if(! $menu_name) return false; $menu_locations = get_nav_menu_locations(); if(! isset($menu_locations[$menu_name])) return false; $menu_obj = get_term($menu_locations[$menu_name], 'nav_menu'); if(! $menu_obj) return false; $menu_id = $menu_obj->term_id; $url = get_permalink($post->ID); $homeurl = get_home_url().'/'; $args = array('order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true, 'update_post_term_cache' => false); $items = wp_get_nav_menu_items($menu_id, $args); if(!count($items) > 0) return false; $children = array(); $i = 0; foreach($items as $parent) { if($parent->post_status == 'publish' && $parent->menu_item_parent != '0') // Is child { $page_id = $parent->menu_item_parent; $children[$page_id][$i]['url'] = $parent->url; $children[$page_id][$i]['title'] = $parent->title; $i++; } } $menu = ''; $menu .= ' 

    '; foreach($items as $item) // Loop through and get top level items { if($item->post_status == 'publish' && $item->menu_item_parent == '0') // Is top level { if(array_key_exists($item->ID, $children)) // If has children { $menu .= ' 
    '; $menu .= ''.$item->title.''; $menu .= ' 
     '; foreach($children[$item->ID] as $child) { if($url === $item->url) { $menu .= ' 
     '.$child['title'].' 
     '; } else { $menu .= ' 
     '.$child['title'].' 
     '; } } $menu .= ''; $menu .= ' 
    '; } else { if($url === $item->url || $homeurl === $item->url) { $menu .= ' 
    '.$item->title.' 
    '; } else { $menu .= ' 
    '.$item->title.' 
    '; } } } } $menu .= ' 

'; echo $menu; } function build_menu_footer($menu_name) { if(! $menu_name) return false; $menu_locations = get_nav_menu_locations(); if(! isset($menu_locations[$menu_name])) return false; $menu_obj = get_term($menu_locations[$menu_name], 'nav_menu'); if(! $menu_obj) return false; $menu_id = $menu_obj->term_id; $url = get_permalink($post->ID); $homeurl = get_home_url().'/'; $args = array('order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true, 'update_post_term_cache' => false); $items = wp_get_nav_menu_items($menu_id, $args); if(!count($items) > 0) return false; $children = array(); $i = 0; foreach($items as $parent) { if($parent->post_status == 'publish' && $parent->menu_item_parent != '0') // Is child { $page_id = $parent->menu_item_parent; $children[$page_id][$i]['url'] = $parent->url; $children[$page_id][$i]['title'] = $parent->title; $i++; } } $menu = ''; $width = array('wp39','wp22','wp24','wp15'); $i=0; $column1 = true; $st = 0; foreach($items as $item) // Loop through and get top level items { if($item->post_status == 'publish' && $item->menu_item_parent == '0') // Is top level { if(array_key_exists($item->ID, $children)) // If has children { $menu .= ' 
'; $menu .= ' 
'.$item->title.' 
'; $menu .= ' 

    '; foreach($children[$item->ID] as $child) { if($column1){ $class = ($st%2!=0)?"wp44":"wp46"; if($url === $item->url) { $menu .= ' 
    '.$child['title'].' 
    '; } else { $menu .= ' 
    '.$child['title'].' 
    '; } } else { if($url === $item->url) { $menu .= ' 
    '.$child['title'].' 
    '; } else { $menu .= ' 
    '.$child['title'].' 
    '; } } $st++; } if($column1){ $menu .= ' 
    '; } $menu .= ' 

'; $column1 = false; $menu .= ' 
'; } else { if($url === $item->url || $homeurl === $item->url) { $menu .= ' 
'; $menu .= ' 
'.$item->title.' 
'; $menu .= ' 
'; } else { $menu .= ' 
'; $menu .= ' 
'.$item->title.' 
'; $menu .= ' 
'; } } $i++; if($i%4==0){ $menu .= ' 
'; $i=0; } } } echo $menu; } function year_format($year){ if($year<10){ return '0'.$year; } return $year; } function head_img($image){ if($image){ $image=$image['sizes']['page-header']; echo 'style="background-image: url('.$image.');"'; } else { $image=get_field('default_header_image','options'); echo 'style="background-image: url('.$image['sizes']['page-header'].');"'; } } function custom_excerpt_length($length) { return 45; } add_filter('excerpt_length', 'custom_excerpt_length', 999); /*function add_jquery_data() { global $post_type; if (isset($_GET['action']) && $_GET['action'] == 'edit' && $post_type='programs') { ?> 'http://www.ipam.ucla.edu/elements/choose.aspx?pc='.strtolower(get_field('program_code'))), $atts)); return ''.$title.''; } return false; } function programEmailShortcode() { if(get_field('program_code')){ return ''.strtolower(get_field('program_code')).'@ipam.ucla.edu'; } return false; } function programCategory($post,$parentCode){ // show to which long program is set $workshopOrLecture=array(48,52); $partOfProgram=array(); if(trim($parentCode)!='' && in_array($post->post_parent,$workshopOrLecture)){ $args = array('post_parent' => 41, 'post_type' => 'programs', 'posts_per_page' => 1, 'post_status' => array('publish'), 'meta_query' => array('relation' => 'AND', array('key' => 'program_code', 'value' => $parentCode, 'compare' => '=',), array('key' => 'program_code', 'value' => '', 'compare' => '!=',))); $partOfProgram = new WP_Query($args); $partOfProgram=$partOfProgram->posts; $partOfProgram=reset($partOfProgram); } if(count($partOfProgram)>0 && !empty($partOfProgram)){ return 'Part of the Long Program: '.$partOfProgram->post_title; } return 'Program Category: '.get_the_title($post->post_parent); } add_shortcode("application_deadline", "applicationDeadlineShortcode"); add_shortcode("registration_link", "registrationLinkShortcode"); add_shortcode("program_email", "programEmailShortcode"); post_parent); ?> 
> 
post_parent){?> post_parent);?> 
/

也有打開WP_DEBUG後出現的錯誤箱:

(!) Notice: Undefined variable: categorie in C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php on line 17 
Call Stack 
# Time Memory Function Location 
1 0.0000 133440 {main}() ..\index.php:0 
2 0.0010 135352 require('C:\wamp\www\ipam.com\wp-blog-header.php') ..\index.php:17 
3 0.8550 15473264 require_once('C:\wamp\www\ipam.com\wp-includes\template-loader.php') ..\wp-blog-header.php:16 
4 0.8730 15592192 include('C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php') ..\template-loader.php:74 

(!) Notice: Trying to get property of non-object in C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php on line 17 
Call Stack 
# Time Memory Function Location 
1 0.0000 133440 {main}() ..\index.php:0 
2 0.0010 135352 require('C:\wamp\www\ipam.com\wp-blog-header.php') ..\index.php:17 
3 0.8550 15473264 require_once('C:\wamp\www\ipam.com\wp-includes\template-loader.php') ..\wp-blog-header.php:16 
4 0.8730 15592192 include('C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php') ..\template-loader.php:74 
(!) Notice: Undefined variable: categorie in C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php on line 20 Call Stack #TimeMemoryFunctionLocation 10.0000133440{main}()..\index.php:0 20.0010135352require('C:\wamp\www\ipam.com\wp-blog-header.php')..\index.php:17 30.855015473264require_once('C:\wamp\www\ipam.com\wp-includes\template-loader.php')..\wp-blog-header.php:16 40.873015592192include('C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php')..\template-loader.php:74 
(!) Notice: Trying to get property of non-object in C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php on line 20 
Call Stack 
# Time Memory Function Location 
1 0.0000 133440 {main}() ..\index.php:0 
2 0.0010 135352 require('C:\wamp\www\ipam.com\wp-blog-header.php') ..\index.php:17 
3 0.8550 15473264 require_once('C:\wamp\www\ipam.com\wp-includes\template-loader.php') ..\wp-blog-header.php:16 
4 0.8730 15592192 include('C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php') ..\template-loader.php:74 
"> 
(!) Notice: Undefined variable: categorie in C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php on line 20 
Call Stack 
# Time Memory Function Location 
1 0.0000 133440 {main}() ..\index.php:0 
2 0.0010 135352 require('C:\wamp\www\ipam.com\wp-blog-header.php') ..\index.php:17 
3 0.8550 15473264 require_once('C:\wamp\www\ipam.com\wp-includes\template-loader.php') ..\wp-blog-header.php:16 
4 0.8730 15592192 include('C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php') ..\template-loader.php:74 

(!) Notice: Trying to get property of non-object in C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php on line 20 
Call Stack 
# Time Memory Function Location 
1 0.0000 133440 {main}() ..\index.php:0 
2 0.0010 135352 require('C:\wamp\www\ipam.com\wp-blog-header.php') ..\index.php:17 
3 0.8550 15473264 require_once('C:\wamp\www\ipam.com\wp-includes\template-loader.php') ..\wp-blog-header.php:16 
4 0.8730 15592192 include('C:\wamp\www\ipam.com\wp-content\themes\ipam\404.php') ..\template-loader.php:74 
/
+0

什麼是**的WordPress服務器**? – Xatenev

+0

1.您是如何更改網站的根名稱(如何)以及如何設置它的。 2.你能從網站上查看你的源代碼嗎 - 你是否收到類似「」(你看到雙引號)? – Xatenev

+0

不管怎樣,第一個錯誤就是說,你正在使用jQuery而沒有加載它。 – Xatenev

回答

1

你將不得不創建一個虛擬主機,以便爲某些PHP函數tions正常工作。 WordPress使用它們:

這是一個例子虛擬主機,你必須在

C:\wamp\bin\apache\Apache2.4.4\conf\extra

<Virtualhost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "C:\wamp\www\yourProject\web" 
    ServerName yourProject.localhost.de 
    ErrorLog "logs/yourProject-error.log" 
    CustomLog "logs/yourProject-access.log" common 
</VirtualHost> 

藏漢創建它,你必須取消對該行

Include conf/extra/httpd-vhosts.conf

像這樣你的虛擬主機文件會得到loa DED。

你必須做出最後的變化是

127.0.0.1 yourProject.localhost.de

說明建立在位於主機文件中的條目:127.0.0.1是本地PC。 yourProject.localhost.de是您可以用來訪問該網站的域。

現在您必須重新啓動您的wamp服務器並通過輸入「yourProject.localhost.de」來訪問您的項目。請記住在wordpress配置中更改ROOT_URL。

其他典型的問題由另一臺服務器上設置一個WordPress實例:

一個問題與報價,WordPress使用不同的報價。像這樣,你有時會收到雙引號。

簡單的解決方法是將此代碼添加到您的functions.php坐落在你的主題,這樣你刪除所有奇怪的WordPress過濾器

remove_filter('the_content', 'wptexturize'); 
remove_filter('the_title', 'wptexturize'); 
remove_filter('the_excerpt', 'wptexturize'); 
remove_filter('comment_text', 'wptexturize'); 
remove_filter('the_content', 'wpautop'); 
+0

好的虛擬主機擺脫了所有這些錯誤,remove_filter代碼已經由設計WP站點的人員實現。我現在得到的是「您無權訪問此服務器上的/ipam.com/」。 – mattgcon

+0

我做了更改,但現在我的Apache服務器無法啓動 – mattgcon

+0

@mattgcon可能是,您設置了錯誤的路徑,請單擊底部欄中的圖標查看錯誤日誌。確保你所有的虛擬主機路徑都是正確的。 – Xatenev