我的网站设计了媒体查询,以涵盖不同大小的布局.我有砌体在全尺寸宽度组织一堆浮子,没问题.在移动宽度,所有浮动,浮动,只是堆叠在彼此之上.所以当768px <= width <= 1000px时,当网站调整为平板电脑布局时,我只需要重新运行砌体.
<script type="text/javascript">
//<![CDATA[
$(document).ready(function($){
$('ul.xoxo').masonry({ singleMode: true, itemSelector: '.widgetcontainer' });
//If the User resizes the window, adjust the #container height
$(window).bind("resize", resizeWindow);
function resizeWindow( e ) {
var newWindowWidth = $(window).width();
if(newWindowWidth<1008){
$('ul.xoxo').masonry();
} else {
$('ul.xoxo').masonry();
}
}
});
/* ]]> */
</script>
Run Code Online (Sandbox Code Playgroud)
这对我来说不起作用,但我也不希望它在所有调整大小上运行......只是在断点处.
如果我有一些单选按钮:
<input type="radio" name="test" value="apple"> Apple<br/>
<input type="radio" name="test" value="banana" CHECKED> Banana<br/>
<input type="radio" name="test" value="carrot"> Carrot<br/>
Run Code Online (Sandbox Code Playgroud)
然后我用jQuery定义了无线电组
var test = $('input:radio[name="test"]')
Run Code Online (Sandbox Code Playgroud)
如何在不重写的情况下基于变量test获取checked元素的值
var test_val = $('input:radio[name="test"]:checked').val();
Run Code Online (Sandbox Code Playgroud)
我试过了两个
$(test):checked.val();
test:checked.val();
Run Code Online (Sandbox Code Playgroud)
作为变更函数的一部分,我也试过这个:
$(test).change(function() {
if ($(this):checked.val() == 'no') {
$('#featured').stop().fadeOut();
} else if ($(this):checked.val() == 'yes') {
$('#featured').stop().fadeIn();
}
});
Run Code Online (Sandbox Code Playgroud)
只是想知道这是否可行,或者我是否必须重新写出完整的输入选择器来获取值.
PS
如果IE8不支持:checked选择器,我可以使用什么?
我有一些自定义代码,可以将项目添加到购物车,这是一个可变产品.如果我添加两次相同的产品,它只会增加数量.我希望它再次添加产品作为购物车中的不同项目.
我该怎么做呢?该项目正在使用domain.com?add-to-cart=3434&variation_id=4434等链接添加到购物车.
我开发的系统是产品设计师.所以我可能想要选择相同的产品,但是以不同的方式设计它,然后将相同的变化添加到购物车.
是否还有一种方法可以在网址中发送唯一标识符来拆分这些项目?
我想通过使用add_to_cart来做到这一点,但每次我使用变体属性,运输最终都有一个错误,它基本上似乎无法找到运输方法:
$woocommerce->cart->add_to_cart(522,1, 523,array("attribute_colour" => "colour","attribute_size" => "a3", "attribute_invoice-numbering" => "yes", "attribute_quantity-column" => "yes", "attribute_cc-type" => "duplicate"));
Run Code Online (Sandbox Code Playgroud)
当该代码将项目添加到购物车时,会导致以下情况:
警告:在第291行的/home/****/public_html/wp-content/plugins/woocommerce/includes/class-wc-shipping.php中为foreach()提供的参数无效
似乎没有任何可用的运输方法.请仔细检查您的地址,或者如果您需要任何帮助,请与我们联系.
它没有任何意义,因为woocommerce中的标准添加到购物车代码使用add_to_cart并且没有这些问题.如果我使用URL,它也可以正常工作!
我正在努力通过我的functions.php 获取元数据以正确过滤。
如果我在我的子主题中编辑 meta.php 没有问题,我可以让它工作:
(简短的故事 - 但因为我使用的是 Avada 主题 - 他们在升级时更改了子主题的位置,我选择了 functions.php)
我目前正在尝试以这种方式过滤元数据:
add_filter ('woocommerce_product_meta_start','add_pet_info' );
function add_pet_info($pet_info) {
$string ="Test Text";
return $pet_info . $string; }
Run Code Online (Sandbox Code Playgroud)
我想得到这个结果:
但我就是无法让它工作。
任何想法我在这里缺少什么?
谢谢!
我正在研究一些自定义帖子类型。我完成了第一个,并意识到我正在使用的元框代码可以被其他未来的自定义帖子类型(以及页面、帖子等)重复使用。因此,我将该类放入其自己的 php 文件中,并将其包含在我的子主题的functions.php 文件中。我以前从未使用过类,但我想我可以从任何我想要的地方调用该类,因为这就是我对函数所做的。相反,我从 post-types.php 文件中调用它并收到以下错误:
“致命错误:在第 73 行的 D:\helga\xampp\htdocs\plagueround\wp-content\themes\plagueround_new2\functions\post-types.php 中找不到类 'My_meta_box'”
在我的子主题的functions.php中,我包含了我的类所在的文件:
define('CHILDTHEME_DIRECTORY', get_stylesheet_directory() . '/');
// Meta Box Class - makes meta boxes
require_once(CHILDTHEME_DIRECTORY . 'functions/meta_box_class.php');
Run Code Online (Sandbox Code Playgroud)
这是我的课
//My Meta Box CLASS
//from: http://www.deluxeblogtips.com/2010/05/howto-meta-box-wordpress.html
class My_meta_box {
protected $_meta_box;
// create meta box based on given data
function __construct($meta_box) {
$this->_meta_box = $meta_box;
add_action('admin_menu', array(&$this, 'add'));
add_action('save_post', array(&$this, 'save'));
}
/// Add meta box for multiple post types
function add() {
foreach ($this->_meta_box['pages'] as $page) {
add_meta_box($this->_meta_box['id'], $this->_meta_box['title'], array(&$this, …Run Code Online (Sandbox Code Playgroud) 我如何测试wordpress分类/术语页面是否是另一个术语的孩子?例如,如果我对"组合类别"的分类法是分层的.我的顶级术语是"数字"和"打印".在印刷品中,我有"电视"......还有其他几个.如果我在"电视"档案中,is_tax()和is_tax('电视')一样,但不是is_tax('print').基本上我喜欢'电视'和它的兄弟姐妹表现一种方式,而"数字"的孩子表现另一种方式.
这是可能的,还是单独的分类法最好的服务?
我无法弄清楚如何将奇数/偶数:nth-child()伪类应用于定义列表
<dl>
<dt>green foo</dt>
<dd>green bar</dd>
<dt>red foo</dt>
<dd>red bar</dd>
<dt>green foo</dt>
<dd>green bar</dd>
</dl>
<style>
dl { color: blue }
dd:nth-child(odd) { color:green }
dd:nth-child(even) { color:red }?
</style>
Run Code Online (Sandbox Code Playgroud)
新小提琴:
使用正确的:nth-of-type伪类.
dd:nth-of-type(even) {color: red;}
dt:nth-of-type(even) {color: red;}
dd:nth-of-type(odd) {color: green;}
dt:nth-of-type(odd) {color: green;}
Run Code Online (Sandbox Code Playgroud)
我正在为WooCommerce开发一个插件.我想覆盖admin的订单详细信息模板.我已经阅读了https://www.skyverge.com/blog/override-woocommerce-template-file-within-a-plugin/,但我仍然不明白如何覆盖admin的订单详细信息模板.以下是我的代码:
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
if ( ! class_exists( 'Test' ) ) {
load_plugin_textdomain( 'test', false, dirname( plugin_basename( __FILE__ ) ) . '/' );
}
}
class Test {
public function __construct() {
add_action( 'init', array( $this, 'include_template_functions' ), 20 );
add_action( 'woocommerce_init', array( $this, 'woocommerce_loaded' ) );
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
do_action( 'woocommerce_admin_order_data_after_order_details', 'hello' );
}
public function hello() {
echo "order detail template has …Run Code Online (Sandbox Code Playgroud) 我想过滤 WP_Query 以检索(post_type = shop_order)具有超过 15 分钟的特定状态的所有 woocommerce 订单。
即所有上次修改日期或之前的帖子(现在 - 15 分钟)// 希望我清楚。
下面是我尝试过的
function filter_where($where = '') {
//posts in the last 15 minutes
$where .= " AND post_modified > '" . date('Y-m-d', strtotime('INTERVAL 15 MINUTE')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
$args = array(
'post_type' => 'shop_order',
'post_status' => 'publish',
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'field' => 'slug',
'terms' => array('completed')
)
)
);
$loop = new WP_Query( $args …Run Code Online (Sandbox Code Playgroud) 我想获取 WooCommerce 中的所有产品数据(产品 sku、名称、价格、库存数量、可用性等)我可以使用 wp-query 来做到这一点吗?