• 締切済み

【PHP】index.phpの実行エラー

themeという関数エラーと思いますが、どのようにしたらindex.phpを正常に実行できるでしょうか。 この(ダミー?)関数の意味と、宣言はどうすればよいでしょうか。 今日初めてPHPを触り、何もわからず恐縮です。よろしくお願いします。 状況: 1)WinXPに、PHP phpdevで、Apache/PHP(Version 4.2.3)/MySQLをインストール。 2)Apache、PHP、MySQLはRun状態。 3)以下のソースのindex.phpを C:\phpdev\www\MagPress というフォルダに配置 4)http://localhost/MagPress を実行すると、以下のエラーが出る。 Fatal error: Call to undefined function: get_header() in c:\phpdev\www\magpress\index.php on line 1 index.phpのソース: ------------------------------------ <?php global $theme; get_header(); ?> <div id="main"> <?php $theme->hook('main_before'); ?> <div id="content"> <?php $theme->hook('content_before'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); /** * The default post formatting from the post.php template file will be used. * If you want to customize the post formatting for your homepage: * * - Create a new file: post-homepage.php * - Copy/Paste the content of post.php to post-homepage.php * - Edit and customize the post-homepage.php file for your needs. * * Learn more about the get_template_part() function: http://codex.wordpress.org/Function_Reference/get_template_part */ get_template_part('post', 'homepage'); endwhile; else : get_template_part('post', 'noresults'); endif; get_template_part('navigation'); ?> <?php $theme->hook('content_after'); ?> </div><!-- #content --> <?php get_sidebars(); ?> <?php $theme->hook('main_after'); ?> </div><!-- #main --> <?php get_footer(); ?>

みんなの回答

  • pluto1234
  • ベストアンサー率84% (11/13)
回答No.1

MagPress は WordPress のテーマなので、WordPress をインストールして、しかるべき場所(wp-contnt/themes) に MagPress を設置しないと動きません。

関連するQ&A

  • WPでphpファイルにエラーが出る

    attitudeというテーマのphpデータに最新記事のお知らせを表示させたいと思っています そこで下記のデータを加えると、最後の<php? get_footer() ?;>になぜかシンタックスエラーが出てきます <?php global $post; $top_news = get_posts( array( 'category_name' => 'info' , //カテゴリースラッグはinfo 'posts_per_page' => 5, //1ページでの表示件数 ) ); ?> <ul class="postsList"> <?php foreach( $top_news as $post ) : setup_postdata($post); ?> <li><?php the_title(); ?></li> </ul> <?php wp_reset_postdata(); ?> <ul>より下を削除するとエラーが消えます。 何卒、宜しくお願いいたします。 以下はページ全体のコードです。参考にお願いします。 <?php /** * Template Name: Business Template * * Displays the Business Layout of the theme. * * @package Theme Horse * @subpackage Attitude * @since Attitude 1.1 */ ?> <?php get_header(); ?> <?php /** * attitude_before_main_container hook */ do_action( 'attitude_before_main_container' ); ?> <div id="container"> <?php /** * attitude_business_template_content hook * * HOOKED_FUNCTION_NAME PRIORITY * * attitude_display_business_template_content 10 */ do_action( 'attitude_business_template_content' ); ?> </div><!-- #container --> <?php /** * attitude_after_main_container hook */ do_action( 'attitude_after_main_container' ); ?> <?php global $post; $top_news = get_posts( array( 'category_name' => 'info' , //カテゴリースラッグはinfo 'posts_per_page' => 5, //1ページでの表示件数 ) ); ?> <ul class="postsList"> <?php get_footer(); ?> ーーーーーーーーーーーーーー

    • 締切済み
    • PHP
  • PHP記述エラーについて。

    PHPの記述のおかしなところ。 wordpressのテーマをそのまま使用しています。 一部 Warning: Invalid argument supplied for foreach() in …略(URL)… front-page.php on line 9 と警告が出ておかしいところがあるようです。 front-page.php の記述は以下です。 <?php get_header(); ?> <div id="primary"> <div id="content" role="main"> <?php $cats = Padd_Option::get('featured_categories', array('1', '2', '3', '4')); $i = 1; foreach ($cats as $cat) { padd_featured_categories_items($cat, 'cat-no-' . $i); $i++; } ?> <div class="clear"></div> </div><!-- #content --> </div><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?> PHPは勉強中なのですが、まだまだ分からない事ばかりで、 自力ではどうにもならず。 詳しい方教えて下さい。 宜しくお願いします。

    • ベストアンサー
    • PHP
  • WordPress 条件分岐間違っている箇所は?

    WordPressで最新記事を判別して大きく見せるなど、表示を変更する条件分岐のカスタマイズ方法を下記のURLを参考に改造しました。 https://whitebear-seo.com/wordpress-newpost-conditional-branch/ 結果はエラーが出ました。 どこが間違っているか教えていただけないでしょうか? 宜しくお願いします。 <?php if ( have_posts() ) : if ( is_home() && ! is_front_page() ) : ?> <?php endif; /* 改造前 */ while ( have_posts() ) : the_post(); /* 改造前 */ get_template_part( 'template-parts/content', get_post_format() ); /* ページネーション */ endwhile; echo '<div class="text-center paging-navs">'; the_posts_pagination(); echo '</div>'; else : get_template_part( 'template-parts/content', 'none' ); /* ページネーション END */ endif; ?> /* 改造後 */の部分だけ改造しました。 ↓ <?php if ( have_posts() ) : if ( is_home() && ! is_front_page() ) : ?> <?php endif; /* 改造後 */ while ( have_posts() ) : the_post(); $counter++; if ($counter <= 1): ? get_template_part( 'template-parts/content2', get_post_format() ); else: /* 改造後 */ get_template_part( 'template-parts/content', get_post_format() ); /* ページネーション */ endwhile; echo '<div class="text-center paging-navs">'; the_posts_pagination(); echo '</div>'; else : get_template_part( 'template-parts/content', 'none' ); /* ページネーション END */ endif; ?>

    • 締切済み
    • PHP
  • PHPについて質問です。

    PHPのCMS機能を応用して既存のPHPファイル(例ではindex.php)の指定した場所にフォームの内容を追記していくシステムを作りたいのですがよくわかりません。 文字だけだとわかりにくいため簡単な例を 参考サイト→http://php.muzin.org/miniblog/ [[index.php (追記したいファイル)]] <html><head> </head> <body> <div></div> //テンプレート {{次からここに追記したい}} </body></html> [[template.php (テンプレート)]] <div><%PAGECONTENTS></div> [[new.php(フォーム)]] <html><head> <form action="makefile.php" method="POST"> <textarea name="honbun" rows="5" cols="50"></textarea><br /> <input type="submit" value="送信" /> </form> </head> </html> [[makefile.php(追記するためのプログラム)]] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=euc-jp"> </head> <body> <?php if ($_POST{"honbun"}) { //フォームに記入されていればファイル生成開始 $honbun = $_POST{"honbun"}; //文字コードをEUCに変換 $honbun = mb_convert_encoding($honbun, "EUC-JP","AUTO"); //クオーテーションマークを変換 if(get_magic_quotes_gpc()) { $honbun = stripslashes($honbun); } // index.phpに追記 $filename = "index.php"; // ファイル生成&書き込み $handle = fopen( $filename, 'w'); fwrite( $handle, $honbun); fclose( $handle ); // メッセージ表示 echo $filename. "に追記しました"; } else { echo "フォームから記事の内容を送信してください。"; } ?> </body> </html> 以上です。 このままだとお察しの通りindex.phpの</html>の後に<div></div>が記入されてしまいます(多分)。 これのどこを変えればindex.phpの{{次からここに追記したい}}の場所に追記することができますか? わかりにくい場合は言ってもらえれば追記します。 回答よろしくお願いします。

    • ベストアンサー
    • PHP
  • index.phpをindex.htmlにしたい

    htmlをphpとして動かすのではなく、拡張子がphpのものをhtmlとして動作させる事はできないのでしょうか。 特に公開する訳ではなく練習でホームページを作っており、index.htmlをindex.phpに変更し、その二つを同じ挙動にしたいです。 ドメイン名+index.phpでアクセスすればサイトは全体的に動作するのですが、ドメインのみでアクセスした場合、index.phpは表示されますが別のリンクからindex.phpに飛ぼうとするとうまく表示されません。これは、html拡張子の場合発生しません。 bootstrapを使用したレスポンシブのテンプレートを使用しています。 実際にphpを動作させたいのではなく、index.phpというファイルをindex.htmlと同じ様に動作させたいのです。二つのファイルの中身は全く一緒です。 ドメインのみでアクセスし、サイト内のどのリンクからトップページに飛んでも問題なく表示され、アドレスの欄にはindex.phpと表示させたいです。 変わった質問ですが、どうぞよろしくお願いします。

  • ワードプレス 最新記事1件だけ大きく表示

    トップページに記事一覧をリストしたものを表示させます。 最新記事1件だけ大きく表示し、以降は普通にしたいです。 検索しましたところ、参考サイトを見つけました。 https://naifix.com/latest-article-new/ これらのプログラム記述が現在使用しているTeemaのプログラムが違っています。 以下が現在使用しているTeemaのプログラム(index.php) get_template_part( 'template-parts/content' 記事一覧リストは「template-parts」フォルダ内にある「content.php」 を使用するといったものです。 最新記事の1件だけ「content2.php」を使用し、以降は「content.php」 を使用するといった記述が分からないのです。 アドバイスをお願いします。 <?php if ( have_posts() ) : if ( is_home() && ! is_front_page() ) : ?> <header> <h1><?php single_post_title(); ?></h1> </header> <?php endif; while ( have_posts() ) : the_post(); get_template_part( 'template-parts/content', get_post_format() ); endif; ?>

    • 締切済み
    • PHP
  • wordpress カスタム投稿タイプについて

    カスタム投稿タイプにより、カタログサイトを作っているのですがwp-pagenaviがページ送りがうまくいきません。phpはよくわからないのでご指導いただければと書き込みました。 状況は下記の通りです。 ■index-frame.php (カスタムテンプレートとして、フレームカタログ一覧を表示。wp-pagenaviはこのphp内に表記しています。) パーマリンクは/%category%/%post_id%/ に設定 index-frame.phpによりサムネイルを表示させ、wp-paginaviでページ送りするとカスタム投稿タイプから投稿済みの別のサムネイルを表示させたいのですが、そうならず、index.phpが使用されてカスタム投稿タイプのタイトルと本文が表示されてしまいます。 サイトURL (”フレーム”に関しての表示部分です。)  http://cm-creation.net/yoshida/localwork/megane-catalog/frame/ index-frame.phpの表記は下記のとおりです。 <?php /* Template Name:インデックス・フレームのテンプレート */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" /> <title><?php bloginfo('name');?><?php wp_title(); ?></title> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css"/> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <div id="head-section"> <div id="header"> <h1><a href="#"><?php bloginfo('name'); ?></a></h1> </div> </div> <div id="wrapper-section"> <div class="clearfix" id="wrapper"> <!--カテゴリーナビ用フレーム強調--> <div id="cate_navi_container"> <?php wp_nav_menu(array( 'theme_location' => 'framebar', 'link_before' => '<img src="' . get_bloginfo('template_url') . '/images/', 'link_after' => '" alt="*" />' )); ?> </div> <!--サイドメニュー用--> <div class="clearfix" id="side-container"> <div id="sidebar"> <?php wp_nav_menu(array( 'theme_location' => 'sidebar', 'depth' => '2' )); ?> </div> </div> <!--メインコンテンツ用--> <div class="clearfix" id="main-container"> <?php if(have_posts()): while(have_posts()): the_post(); ?> <div class="title"> <h2><?php the_title(); ?></h2> <?php the_content(); ?> </div> <?php endwhile; endif; ?> <div class="itemlist"> <?php query_posts('post_type='.$post->post_name); ?> <?php if(have_posts()): while(have_posts()): the_post(); ?> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('ssize'); ?> </a> <?php endwhile; endif; ?> </div> <div id="pagenavi"> <!--ロールナビゲーション--> <div id="roll"><?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { vicuna_paging_link('next_label=Newer Entries&prev_label=Older Entries&indent=2'); } ?> </div> </div> </div> </div> </div> <?php get_footer(); ?> カスタム投稿タイプとwp-pagneviの問題についてネットで見ましたが、すいません、phpについてよくわかっておらずどこをどう表記変更したら良いかわからずにおります。よろしくお願いいたします。

    • ベストアンサー
    • PHP
  • PHP実行時のエラーについて

    質問よろしくお願いいたします。 PHP初心者なのですが、 サイト更新のし易さなどから ’ウェブランサー’というサイトのテンプレートを使わせて頂き、 試行錯誤しながら現在サイト構築を進めています。 動作確認にはXAMPPというフリーソフトを使っているのですが、 どうやらエラーが出ているようなのですが、 なにが原因なのかよくわかりません。 分かる方いらっしゃいましたら、教えて頂けないでしょうか? Deprecated: Function ereg() is deprecated in C:\xampp\htdocs\public_html\index.php on line 2 これは何のエラーなのでしょうか? 自分なりにネットで調べても、英語サイトばかり引っ掛かり 原因が分からないでいます。 現在 public_html のフォルダーには、2つのファイルがありまして (ウェブランサーさんのテンプレートです。) どちらかが原因なのでしょうか? ■1つめのファイル(temp.php) <?php /***********************************/ // 使いまわす部品の用意 /***********************************/ // ドメイン(ファイルを設置するディレクトリまで定義) $domain = "http://".$_SERVER["HTTP_HOST"]."/"; // XML宣言 $xml_v = "<?xml version=\"1.0\" encoding=\"Shift_JIS\" ?>"; $body_text = "#000000"; $body_bg = "#FFFFFF"; $body_link = "#0000FF"; $body_vlink = "#0000FF"; $body_alink = "#0000AA"; $hr = "<hr style=\"border-color:#999999; border-style:solid;\" />"; $san = "<span style=\"color:#999999;\">…………………………</span>"; /***********************************/ // ヘッダーを定義 /***********************************/ $header = <<< TAGSET {$xml_v} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-Type" content="application/xhtml+xml; charset=Shift_JIS" /> <title>{$title}</title> <meta name="keywords" content="{$keyword}" /> <meta name="description" content="{$description}" /> <link rel="alternate" media="handheld" href="alternate_page.htm" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <style type="text/css"> <![CDATA[ a:link{color: {$body_link};} a:visited{color: {$body_vlink};} a:focus{color: {$body_alink};} ]]> </style> </head> <body text="{$body_text}" bgcolor="{$body_bg}" link="{$body_link}" vlink="{$body_vlink}" alink="{$body_alink}" style="color:{$body_text}; background-color:{$body_bg};"> TAGSET; /***********************************/ // フッターを定義 /***********************************/ $footer = <<< TAGSET {$hr} <div style="text-align:center; font-size:x-small;">(C)Sample.</div> </body> </html> TAGSET; ?> ■2つめのファイル(index.php) <?php if (ereg("DoCoMo", $_SERVER['HTTP_USER_AGENT'])) { header('Content-Type: application/xhtml+xml'); } $title = "このページのタイトル"; $keyword = "キーワード"; $description = "このページの説明文。"; include("./temp.php"); echo $header; ?> <!--=== CONTENTS ===--> コンテンツ部分を記述 <!--/=== CONTENTS ===--> <?php echo $footer; ?> これらのファイルをXAMPPで開くと、 以下のエラーがページ内に出ています。 Deprecated: Function ereg() is deprecated in C:\xampp\htdocs\public_html\index.php on line 2 コンテンツ部分を記述 -------------------------------------------------------------------------------- (C)Sample. 本来は、コンテンツ部分を記述がページ文頭にこないと おかしいと思うのですが…。 これの原因分かる方いらっしゃいますか?

    • ベストアンサー
    • PHP
  • WORDPRESSのfunctions.php

    こんばんは。 タイトルの「functions.php」のカスタマイズについて、いろんなサイトで書かれています。 http://www.webcreatorbox.com/tech/customize-wordpress-admin-page/ 私も試そうと思っていますが、「wp-content/themes/(テーマ名)」の中と「wp-includes」の中と2つあります。 どっちのことでしょうか?

    • 締切済み
    • CSS
  • POSTでUndefined indexのエラー

    ページを表示すると Notice: Undefined index: sub in C:\apache\htdocs\post.php on line 13 といったエラーがでてしまいます。 <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <title></title> </head> <body> <form action="#" method="POST"> <input type="submit" name="sub" value="GO"> </form> <?php print $_POST["sub"]; ?> </body> </html> intoで作ったGOボタンを押すとエラーは消えるのですが、 書き方は間違っていないと思うのずですが、 もしかしてphp.iniの設定が必要?とかでしょうか。

    • ベストアンサー
    • PHP

専門家に質問してみよう