我在掙扎着一件事。我有這樣的WordPress的功能:如何使wordpress功能只能在單頁和非頁面上工作
function wpq_insert_attachment_data($data, $postarr){
if (!is_single()) {
$posttitle = get_the_title($postarr['post_parent']);
$data['post_title'] = $posttitle;
$data['post_name'] = $posttitle;
return $data;
}}
add_filter('wp_insert_attachment_data', 'wpq_insert_attachment_data', 10, 2);
它的工作原理,但高超它涵蓋所有單/自定義後類型/頁等有沒有辦法排除該功能的網頁?我試着用is_single()
整理出來,但沒有成功。
在這裏看到:http://stackoverflow.com/questions/22070223/how-can-i-use-is-page-inside-a-plugin 比添加掛鉤重定向功能 – Bart
@Bart - 它不起作用。它仍然執行所有類型的元素:posts/pages ..看看更新後的代碼。 –
你可以粘貼你的新代碼嗎? – Bart