質問編集履歴
6
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,6 +6,4 @@
|
|
6
6
|
|
7
7
|
```ここに言語を入力
|
8
8
|
Fatal error: Uncaught Error: Call to undefined function get_filed() in /home/test/www/elc2/wp/wp-content/themes/elc/search.php:75 Stack trace: #0 /home/test/www/elc2/wp/wp-content/themes/elc/functions.php(76): include() #1 /home/test/www/elc2/wp/wp-includes/class-wp-hook.php(286): search_no_keywords('') #2 /home/test/www/elc2/wp/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #3 /home/test/www/elc2/wp/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #4 /home/test/www/elc2/wp/wp-includes/template-loader.php(12): do_action('template_redire...') #5 /home/test/www/elc2/wp/wp-blog-header.php(19): require_once('/home/test/www...') #6 /home/test/www/elc2/index.php(17): require('/home/test/www...') #7 {main} thrown in /home/test/www/elc2/wp/wp-content/themes/elc/search.php on line 75
|
9
|
-
```
|
9
|
+
```
|
10
|
-
|
11
|
-
ちなみにfunctions.phpの76行目には下記サイトを参考にして、下記のようなコードを追加しております。
|
5
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,164 +8,4 @@
|
|
8
8
|
Fatal error: Uncaught Error: Call to undefined function get_filed() in /home/test/www/elc2/wp/wp-content/themes/elc/search.php:75 Stack trace: #0 /home/test/www/elc2/wp/wp-content/themes/elc/functions.php(76): include() #1 /home/test/www/elc2/wp/wp-includes/class-wp-hook.php(286): search_no_keywords('') #2 /home/test/www/elc2/wp/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #3 /home/test/www/elc2/wp/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #4 /home/test/www/elc2/wp/wp-includes/template-loader.php(12): do_action('template_redire...') #5 /home/test/www/elc2/wp/wp-blog-header.php(19): require_once('/home/test/www...') #6 /home/test/www/elc2/index.php(17): require('/home/test/www...') #7 {main} thrown in /home/test/www/elc2/wp/wp-content/themes/elc/search.php on line 75
|
9
9
|
```
|
10
10
|
|
11
|
-
ちなみにfunctions.phpの76行目には下記サイトを参考にして、下記のようなコードを追加しております。
|
11
|
+
ちなみにfunctions.phpの76行目には下記サイトを参考にして、下記のようなコードを追加しております。
|
12
|
-
|
13
|
-
[参考サイト](http://kotori-blog.com/wordpress/refinement_search/)
|
14
|
-
|
15
|
-
```ここに言語を入力
|
16
|
-
function search_no_keywords() {
|
17
|
-
if (isset($_GET['s']) && empty($_GET['s'])) {
|
18
|
-
//URLにパラメータ「s」がついていたらsearch.phpを表示
|
19
|
-
include(TEMPLATEPATH . '/search.php');
|
20
|
-
exit;
|
21
|
-
}
|
22
|
-
}
|
23
|
-
add_action('template_redirect', 'search_no_keywords');
|
24
|
-
```
|
25
|
-
|
26
|
-
追記
|
27
|
-
==
|
28
|
-
プラグインは「Advanced Custom Fields」を使用し追加しております。
|
29
|
-
また、プラグイン「User Role Editor」でユーザーごとの権限の設定や、functions.phpに他のユーザーが投稿したものを触れないように設定しております。
|
30
|
-
```ここに言語を入力
|
31
|
-
/*-------------------------------------------*/
|
32
|
-
/*【管理画面】投稿一覧で他のユーザーが投稿した投稿を非表示
|
33
|
-
/*-------------------------------------------*/
|
34
|
-
function posts_for_current_author($query) {
|
35
|
-
global $user_level;
|
36
|
-
|
37
|
-
if($query->is_admin && $user_level < 5) {
|
38
|
-
global $user_ID;
|
39
|
-
$query->set('author', $user_ID);
|
40
|
-
unset($user_ID);
|
41
|
-
}
|
42
|
-
unset($user_level);
|
43
|
-
|
44
|
-
return $query;
|
45
|
-
}
|
46
|
-
add_filter('pre_get_posts', 'posts_for_current_author');
|
47
|
-
|
48
|
-
/*-------------------------------------------*/
|
49
|
-
/*【管理画面】投稿一覧で他のユーザーが投稿した画像を非表示
|
50
|
-
/*-------------------------------------------*/
|
51
|
-
function display_only_self_uploaded_medias( $query ) {
|
52
|
-
if ( ( $user = wp_get_current_user() ) && ! current_user_can( 'administrator' || 'e-learning' ) ) {
|
53
|
-
$query['author'] = $user->ID;
|
54
|
-
}
|
55
|
-
return $query;
|
56
|
-
}
|
57
|
-
add_action( 'ajax_query_attachments_args', 'display_only_self_uploaded_medias' );
|
58
|
-
|
59
|
-
```
|
60
|
-
|
61
|
-
■search.php
|
62
|
-
```ここに言語を入力
|
63
|
-
<?php get_header(); ?>
|
64
|
-
|
65
|
-
<?php
|
66
|
-
$s = $_GET['s'];
|
67
|
-
$item_tag = $_GET['item'];
|
68
|
-
$genre_tag = $_GET['genre'];
|
69
|
-
$type_tag = $_GET['type'];
|
70
|
-
|
71
|
-
// 配列「ジャンル選択」から空要素を削除
|
72
|
-
$genre_tag = array_filter($genre_tag, "strlen");
|
73
|
-
|
74
|
-
// 配列「タイプ選択」から空要素を削除
|
75
|
-
$type_tag = array_filter($type_tag, "strlen");
|
76
|
-
|
77
|
-
//tax_query用
|
78
|
-
if($item_tag){
|
79
|
-
$taxquerysp[] = array(
|
80
|
-
'post_type' => 'member',
|
81
|
-
'taxonomy'=>'ctcategory',
|
82
|
-
'terms'=> $item_tag,
|
83
|
-
'include_children'=>false,
|
84
|
-
'field'=>'slug',
|
85
|
-
'operator'=>'AND'
|
86
|
-
);
|
87
|
-
$item_name = get_term_by( 'slug', $item_tag, 'ctcategory' );
|
88
|
-
}
|
89
|
-
if($genre_tag){
|
90
|
-
$taxquerysp[] = array(
|
91
|
-
'post_type' => 'member',
|
92
|
-
'taxonomy'=>'ctcategory',
|
93
|
-
'terms'=> $genre_tag,
|
94
|
-
'include_children'=>false,
|
95
|
-
'field'=>'slug',
|
96
|
-
'operator'=>'AND'
|
97
|
-
);
|
98
|
-
$genre_name = get_term_by( 'slug', $genre_tag, 'ctcategory' );
|
99
|
-
}
|
100
|
-
if($type_tag){
|
101
|
-
$taxquerysp[] = array(
|
102
|
-
'post_type' => 'member',
|
103
|
-
'taxonomy'=>'ctcategory',
|
104
|
-
'terms'=> $type_tag,
|
105
|
-
'include_children'=>false,
|
106
|
-
'field'=>'slug',
|
107
|
-
'operator'=>'AND'
|
108
|
-
);
|
109
|
-
$type_name = get_term_by( 'slug', $type_tag, 'ctcategory' );
|
110
|
-
}
|
111
|
-
|
112
|
-
$args = array(
|
113
|
-
'tax_query' => $taxquerysp,
|
114
|
-
's' => $s,
|
115
|
-
);
|
116
|
-
$the_query = new WP_Query( $args );
|
117
|
-
?>
|
118
|
-
<div id="container" class="testContent clear">
|
119
|
-
<div id="main">
|
120
|
-
<h1>検索キーワード</h1>
|
121
|
-
<?php
|
122
|
-
$count = $the_query->post_count;
|
123
|
-
if($count!=0){
|
124
|
-
echo '<p class="searchCount">検索結果 '.$count.'件</p>';
|
125
|
-
}
|
126
|
-
?>
|
127
|
-
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
|
128
|
-
<article class="contentList">
|
129
|
-
<div class="clear">
|
130
|
-
<div class="leftImg">
|
131
|
-
<p>
|
132
|
-
<?php the_title() ?>
|
133
|
-
</p>
|
134
|
-
<?php
|
135
|
-
// カスタムフィールド値取得
|
136
|
-
// 「コンテンツ1_画像」に設定した画像取得
|
137
|
-
$c_img = get_filed("cf1_img");
|
138
|
-
// 「コンテンツ1_見出し」に設定した画像取得
|
139
|
-
$c_title = get_filed("cf1_title");
|
140
|
-
// 「コンテンツ1_テキスト」に設定した画像取得
|
141
|
-
$c_txt = get_filed("cf1_txt");
|
142
|
-
?>
|
143
|
-
<?php echo $c_img ?>
|
144
|
-
|
145
|
-
<?php if($c_img): ?>
|
146
|
-
<img src="<?php echo $c_img ?>" alt="<?php the_title() ?>">
|
147
|
-
<?php else: ?>
|
148
|
-
<img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/common/no-image.png" alt="">
|
149
|
-
<?php endif; ?>
|
150
|
-
</div>
|
151
|
-
<div class="rightTxt">
|
152
|
-
<h2><?php echo $c_title ?></h2>
|
153
|
-
<?php echo $c_txt ?>
|
154
|
-
</div>
|
155
|
-
</div>
|
156
|
-
<a href="<?php the_permalink(); ?>"></a>
|
157
|
-
</article>
|
158
|
-
<?php endwhile; else : ?>
|
159
|
-
|
160
|
-
<div class="notContent">関連する記事は見つかりませんでした。</div>
|
161
|
-
|
162
|
-
<?php endif;
|
163
|
-
wp_reset_postdata(); ?>
|
164
|
-
</div><!-- #main -->
|
165
|
-
<?php get_sidebar(); ?>
|
166
|
-
</div><!-- #container -->
|
167
|
-
|
168
|
-
|
169
|
-
<?php get_footer(); ?>
|
170
|
-
|
171
|
-
```
|
4
情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -56,4 +56,116 @@
|
|
56
56
|
}
|
57
57
|
add_action( 'ajax_query_attachments_args', 'display_only_self_uploaded_medias' );
|
58
58
|
|
59
|
+
```
|
60
|
+
|
61
|
+
■search.php
|
62
|
+
```ここに言語を入力
|
63
|
+
<?php get_header(); ?>
|
64
|
+
|
65
|
+
<?php
|
66
|
+
$s = $_GET['s'];
|
67
|
+
$item_tag = $_GET['item'];
|
68
|
+
$genre_tag = $_GET['genre'];
|
69
|
+
$type_tag = $_GET['type'];
|
70
|
+
|
71
|
+
// 配列「ジャンル選択」から空要素を削除
|
72
|
+
$genre_tag = array_filter($genre_tag, "strlen");
|
73
|
+
|
74
|
+
// 配列「タイプ選択」から空要素を削除
|
75
|
+
$type_tag = array_filter($type_tag, "strlen");
|
76
|
+
|
77
|
+
//tax_query用
|
78
|
+
if($item_tag){
|
79
|
+
$taxquerysp[] = array(
|
80
|
+
'post_type' => 'member',
|
81
|
+
'taxonomy'=>'ctcategory',
|
82
|
+
'terms'=> $item_tag,
|
83
|
+
'include_children'=>false,
|
84
|
+
'field'=>'slug',
|
85
|
+
'operator'=>'AND'
|
86
|
+
);
|
87
|
+
$item_name = get_term_by( 'slug', $item_tag, 'ctcategory' );
|
88
|
+
}
|
89
|
+
if($genre_tag){
|
90
|
+
$taxquerysp[] = array(
|
91
|
+
'post_type' => 'member',
|
92
|
+
'taxonomy'=>'ctcategory',
|
93
|
+
'terms'=> $genre_tag,
|
94
|
+
'include_children'=>false,
|
95
|
+
'field'=>'slug',
|
96
|
+
'operator'=>'AND'
|
97
|
+
);
|
98
|
+
$genre_name = get_term_by( 'slug', $genre_tag, 'ctcategory' );
|
99
|
+
}
|
100
|
+
if($type_tag){
|
101
|
+
$taxquerysp[] = array(
|
102
|
+
'post_type' => 'member',
|
103
|
+
'taxonomy'=>'ctcategory',
|
104
|
+
'terms'=> $type_tag,
|
105
|
+
'include_children'=>false,
|
106
|
+
'field'=>'slug',
|
107
|
+
'operator'=>'AND'
|
108
|
+
);
|
109
|
+
$type_name = get_term_by( 'slug', $type_tag, 'ctcategory' );
|
110
|
+
}
|
111
|
+
|
112
|
+
$args = array(
|
113
|
+
'tax_query' => $taxquerysp,
|
114
|
+
's' => $s,
|
115
|
+
);
|
116
|
+
$the_query = new WP_Query( $args );
|
117
|
+
?>
|
118
|
+
<div id="container" class="testContent clear">
|
119
|
+
<div id="main">
|
120
|
+
<h1>検索キーワード</h1>
|
121
|
+
<?php
|
122
|
+
$count = $the_query->post_count;
|
123
|
+
if($count!=0){
|
124
|
+
echo '<p class="searchCount">検索結果 '.$count.'件</p>';
|
125
|
+
}
|
126
|
+
?>
|
127
|
+
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
|
128
|
+
<article class="contentList">
|
129
|
+
<div class="clear">
|
130
|
+
<div class="leftImg">
|
131
|
+
<p>
|
132
|
+
<?php the_title() ?>
|
133
|
+
</p>
|
134
|
+
<?php
|
135
|
+
// カスタムフィールド値取得
|
136
|
+
// 「コンテンツ1_画像」に設定した画像取得
|
137
|
+
$c_img = get_filed("cf1_img");
|
138
|
+
// 「コンテンツ1_見出し」に設定した画像取得
|
139
|
+
$c_title = get_filed("cf1_title");
|
140
|
+
// 「コンテンツ1_テキスト」に設定した画像取得
|
141
|
+
$c_txt = get_filed("cf1_txt");
|
142
|
+
?>
|
143
|
+
<?php echo $c_img ?>
|
144
|
+
|
145
|
+
<?php if($c_img): ?>
|
146
|
+
<img src="<?php echo $c_img ?>" alt="<?php the_title() ?>">
|
147
|
+
<?php else: ?>
|
148
|
+
<img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/common/no-image.png" alt="">
|
149
|
+
<?php endif; ?>
|
150
|
+
</div>
|
151
|
+
<div class="rightTxt">
|
152
|
+
<h2><?php echo $c_title ?></h2>
|
153
|
+
<?php echo $c_txt ?>
|
154
|
+
</div>
|
155
|
+
</div>
|
156
|
+
<a href="<?php the_permalink(); ?>"></a>
|
157
|
+
</article>
|
158
|
+
<?php endwhile; else : ?>
|
159
|
+
|
160
|
+
<div class="notContent">関連する記事は見つかりませんでした。</div>
|
161
|
+
|
162
|
+
<?php endif;
|
163
|
+
wp_reset_postdata(); ?>
|
164
|
+
</div><!-- #main -->
|
165
|
+
<?php get_sidebar(); ?>
|
166
|
+
</div><!-- #container -->
|
167
|
+
|
168
|
+
|
169
|
+
<?php get_footer(); ?>
|
170
|
+
|
59
171
|
```
|
3
情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -21,4 +21,39 @@
|
|
21
21
|
}
|
22
22
|
}
|
23
23
|
add_action('template_redirect', 'search_no_keywords');
|
24
|
+
```
|
25
|
+
|
26
|
+
追記
|
27
|
+
==
|
28
|
+
プラグインは「Advanced Custom Fields」を使用し追加しております。
|
29
|
+
また、プラグイン「User Role Editor」でユーザーごとの権限の設定や、functions.phpに他のユーザーが投稿したものを触れないように設定しております。
|
30
|
+
```ここに言語を入力
|
31
|
+
/*-------------------------------------------*/
|
32
|
+
/*【管理画面】投稿一覧で他のユーザーが投稿した投稿を非表示
|
33
|
+
/*-------------------------------------------*/
|
34
|
+
function posts_for_current_author($query) {
|
35
|
+
global $user_level;
|
36
|
+
|
37
|
+
if($query->is_admin && $user_level < 5) {
|
38
|
+
global $user_ID;
|
39
|
+
$query->set('author', $user_ID);
|
40
|
+
unset($user_ID);
|
41
|
+
}
|
42
|
+
unset($user_level);
|
43
|
+
|
44
|
+
return $query;
|
45
|
+
}
|
46
|
+
add_filter('pre_get_posts', 'posts_for_current_author');
|
47
|
+
|
48
|
+
/*-------------------------------------------*/
|
49
|
+
/*【管理画面】投稿一覧で他のユーザーが投稿した画像を非表示
|
50
|
+
/*-------------------------------------------*/
|
51
|
+
function display_only_self_uploaded_medias( $query ) {
|
52
|
+
if ( ( $user = wp_get_current_user() ) && ! current_user_can( 'administrator' || 'e-learning' ) ) {
|
53
|
+
$query['author'] = $user->ID;
|
54
|
+
}
|
55
|
+
return $query;
|
56
|
+
}
|
57
|
+
add_action( 'ajax_query_attachments_args', 'display_only_self_uploaded_medias' );
|
58
|
+
|
24
59
|
```
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Call to undefined function get_filed()部分でそんな関数無いぞといわれているのはわかったのですが、それ以降のコードが何を意味しているのか分からない状態です。
|
3
3
|
どなたか教えていただけないでしょうか。
|
4
4
|
|
5
|
-
ちなみに下記コードは、「new WP_Query」で取得した物のループ内でカスタムフィールドを取得しようとして表示されております。
|
5
|
+
ちなみに下記コードは、「search.php」に「new WP_Query」で取得した物のループ内でカスタムフィールドを取得しようとして表示されております。
|
6
6
|
|
7
7
|
```ここに言語を入力
|
8
8
|
Fatal error: Uncaught Error: Call to undefined function get_filed() in /home/test/www/elc2/wp/wp-content/themes/elc/search.php:75 Stack trace: #0 /home/test/www/elc2/wp/wp-content/themes/elc/functions.php(76): include() #1 /home/test/www/elc2/wp/wp-includes/class-wp-hook.php(286): search_no_keywords('') #2 /home/test/www/elc2/wp/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #3 /home/test/www/elc2/wp/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #4 /home/test/www/elc2/wp/wp-includes/template-loader.php(12): do_action('template_redire...') #5 /home/test/www/elc2/wp/wp-blog-header.php(19): require_once('/home/test/www...') #6 /home/test/www/elc2/index.php(17): require('/home/test/www...') #7 {main} thrown in /home/test/www/elc2/wp/wp-content/themes/elc/search.php on line 75
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,4 +6,19 @@
|
|
6
6
|
|
7
7
|
```ここに言語を入力
|
8
8
|
Fatal error: Uncaught Error: Call to undefined function get_filed() in /home/test/www/elc2/wp/wp-content/themes/elc/search.php:75 Stack trace: #0 /home/test/www/elc2/wp/wp-content/themes/elc/functions.php(76): include() #1 /home/test/www/elc2/wp/wp-includes/class-wp-hook.php(286): search_no_keywords('') #2 /home/test/www/elc2/wp/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #3 /home/test/www/elc2/wp/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #4 /home/test/www/elc2/wp/wp-includes/template-loader.php(12): do_action('template_redire...') #5 /home/test/www/elc2/wp/wp-blog-header.php(19): require_once('/home/test/www...') #6 /home/test/www/elc2/index.php(17): require('/home/test/www...') #7 {main} thrown in /home/test/www/elc2/wp/wp-content/themes/elc/search.php on line 75
|
9
|
+
```
|
10
|
+
|
11
|
+
ちなみにfunctions.phpの76行目には下記サイトを参考にして、下記のようなコードを追加しております。
|
12
|
+
|
13
|
+
[参考サイト](http://kotori-blog.com/wordpress/refinement_search/)
|
14
|
+
|
15
|
+
```ここに言語を入力
|
16
|
+
function search_no_keywords() {
|
17
|
+
if (isset($_GET['s']) && empty($_GET['s'])) {
|
18
|
+
//URLにパラメータ「s」がついていたらsearch.phpを表示
|
19
|
+
include(TEMPLATEPATH . '/search.php');
|
20
|
+
exit;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
add_action('template_redirect', 'search_no_keywords');
|
9
24
|
```
|