我创建了一个子主题,并移动了父主题函数中的所有修改。php转换为子主题的函数。php。现在,如果我预览主题,它是空白的。
我有三件事要做——更改云中显示的标签数量、隐藏产品类别和显示谷歌图书预览。
我在这段代码中看不到任何错误,当它在父代码中时,它就会工作。
如果有任何帮助,我将不胜感激,我完全被困住了!
<?php
function change_tag_cloud_widget() {
$args[\'number\'] = 15;
return $args;
}
add_filter( \'widget_tag_cloud_args\', \'change_tag_cloud_widget\' );
add_action( \'pre_get_posts\', \'custom_pre_get_posts_query\' );
function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() ) {
$q->set( \'tax_query\', array(array(
\'taxonomy\' => \'product_cat\',
\'field\' => \'slug\',
\'terms\' => array( \'hands-on\' ), // Don\'t display products in the hands-on category on the shop page
\'operator\' => \'NOT IN\'
)));
}
remove_action( \'pre_get_posts\', \'custom_pre_get_posts_query\' );
}
add_shortcode(\'gbooks\', \'sc_embed_google_books\');
function sc_embed_google_books( $atts ){
extract(shortcode_atts(array(
"id" => \'\',
"width" => \'600\',
"height" => \'900\',
), $atts));
return \'<script type="text/javascript" src="http://books.google.com/books/previewlib.js"></script>
<script type="text/javascript">
GBS_insertPreviewButtonPopup("\'.$id.\'", \'.$width.\',\'.$height.\');
</script>\';
}
function get_google_tag( $isbn_metadata ) {
return (
/* \'<span class="post-meta-key">Preview: </span>\' . */
\'<script type="text/javascript" src="http://books.google.com/books/previewlib.js"></script>\' .
\'<script type="text/javascript">\' .
\'GBS_insertPreviewButtonPopup(\\\'ISBN:\' . $isbn_metadata . \'\\\');\' .
\'</script>\'
);
}
?>