在使用WordPress时,是否可以像在CSS中一样使用CSS获取背景图像.我试过这样做,但它不起作用.
background-image: url("<?php bloginfo('template_directory'); ?>/images/parallax_image.jpg ");
Run Code Online (Sandbox Code Playgroud) 这是我的代码,它在桌面和平板电脑上运行得非常好,但在移动设备上则不行.是代码还是某些字体不能在移动设备上运行
@font-face {
font-family: 'Out';
src: url('http://location/Outstanding.otf');
}
Run Code Online (Sandbox Code Playgroud) 是否可以像Bootstrap Carousel一样使用Slick Slider的HTML来创建自定义分页点。
Bootstrap分页示例
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
Run Code Online (Sandbox Code Playgroud)
我知道您可以像这样创建自定义点;
customPaging : function(slider, i) {
var thumb = $(slider.$slides[i]).data('thumb');
return '<a><img src="'+thumb+'"></a>';
}
Run Code Online (Sandbox Code Playgroud)
但是这种方法不适用于我要实现的目标。这就是我希望能够用作我的分页导航的内容。
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
Run Code Online (Sandbox Code Playgroud)
customPaging : function(slider, i) {
var thumb = $(slider.$slides[i]).data('thumb');
return '<a><img src="'+thumb+'"></a>';
}
Run Code Online (Sandbox Code Playgroud)
jQuery(document).ready(function($){
$('.step').click(function(){
var elem = $(this);
var pointer = $('#pointer');
if( elem.hasClass('one') ){
pointer.css('left', '0');
}else if( elem.hasClass('two') ){
pointer.css('left', '20%');
}else …Run Code Online (Sandbox Code Playgroud)我正在尝试获取我的链接以突出显示用户是否正在滚动链接的页面.但由于某种原因,它无法正常工作.我已经注释了我在jquery中的第一次尝试并再次尝试但链接二是突出显示链接一时应该.
<nav>
<ul>
<li><a href="" id="link_1">Link 1</a></li>
<li><a href="" id="link_2">Link 2</a></li>
<li><a href="" id="link_3">Link 3</a></li>
</ul>
<p></p>
</nav>
<div id="sec_one" class="sections">
</div>
<div id="sec_two" class="sections">
</div>
<div id="sec_three" class="sections">
</div>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
*{
margin: 0;
padding: 0;
}
nav{
width: 100%;
background-color: black;
position: fixed;
top: 0;
}
nav ul{
width: 50%;
margin: 0 auto;
list-style-type: none;
text-align: center;
}
nav ul li{
display: inline;
width: 100%;
}
nav ul li a{
font-size: 40px;
color: white;
text-decoration: none; …Run Code Online (Sandbox Code Playgroud) 我试图像使用自定义帖子类型一样遍历我的WooCommerce产品.但由于某种原因,这种方法不起作用.我收到的错误与我使用有关have_posts().我究竟做错了什么?
错误
未捕获错误:在数组上调用成员函数have_posts()
我的代码
<?php
$query = new WC_Product_Query( array(
'limit' => 10,
'orderby' => 'date',
'order' => 'DESC'
) );
$products = $query->get_products();
if( $products->have_posts() ) {
while( $products->have_posts() ) {
$products->the_post();
echo the_permalink();
}
} ?>
Run Code Online (Sandbox Code Playgroud)
更新
我发现使用foreach循环确实如下所示;
<?php
foreach( $products as $product ) {
echo $product->get_title();
} ?>
Run Code Online (Sandbox Code Playgroud)
但是我仍然想知道为什么这种方法无效 have_posts()
我似乎无法定位用于在联系表单 7 中上传文件的按钮。我如何定位选择文件按钮,以便我可以添加背景颜色等。哦,我也是这样做的 WordPress 以防万一你需要知道那。所以在后端它看起来像这样;
<label class="form_label"> Your Name<span>*</span>
[text* your-name]</label>
<label class="form_label"> Your Email<span>*</span>
[email* your-email]</label>
<label class="form_label">Tel
[tel tel]</label>
<label class="form_label">CV<span>*</span>
[file cv id:upload]</label>
<label class="form_label">Cover Letter
[textarea your-message]</label>
[submit "Send"]
Run Code Online (Sandbox Code Playgroud)
我的输出 html 如下所示。
<label class="form_label"> Your Name<span>*</span>
[text* your-name]</label>
<label class="form_label"> Your Email<span>*</span>
[email* your-email]</label>
<label class="form_label">Tel
[tel tel]</label>
<label class="form_label">CV<span>*</span>
[file cv id:upload]</label>
<label class="form_label">Cover Letter
[textarea your-message]</label>
[submit "Send"]
Run Code Online (Sandbox Code Playgroud)
当我尝试查看购物车、我的帐户和结账页面时,它们都是空白的。我得到的只是页眉和页脚。到目前为止我所做的就是下载 WooCommerce,完成设置并添加主题支持。在添加主题支持之前,我的商店页面无法正常工作,但现在这是唯一可以正常工作的页面。我还注意到,如果我在 php 文件中使用 WooCommerce 短代码,我可以获得页面。但短代码似乎在后端不起作用。顺便说一句,我正在使用我自己的自定义主题,以防相关。
我可以做什么来解决这个问题?
更新:这一定是我的主题的问题,就好像我设置了默认主题之一来激活所有 WooCommerce 页面显示一样。但我还不知道我的主题问题是什么。
我想在产品循环中的这行代码中添加多个bootstrap col类,但我不知道.
<li><?php wc_product_class(); ?></li>
Run Code Online (Sandbox Code Playgroud)
我可以以某种方式推动我的分类到这个位的PHP仍然保持产品应用?
我已经使用平滑滑块在WordPress中创建了图像滑块。我使用的是居中模式,我希望一幅图像居中,每侧略微显示。但是我有一些问题。首先,当我调整窗口平滑滑块的大小时,直到与滑块互动,它才计算出新的图像宽度,这是演示中不存在的问题。其次,每侧的图像都没有显示出来。
https://codepen.io/Reece_Dev/pen/xLQwEb
$('.carousel').slick({
centerMode: true,
centerPadding: '0px',
slidesToShow: 1,
});
Run Code Online (Sandbox Code Playgroud)
#container{
width: 100%;
}
.slick-slide img{
width: 80%;
height: auto;
max-width: 2000px;
}
Run Code Online (Sandbox Code Playgroud)
<script src="//cdn.jsdelivr.net/jquery.slick/1.6.0/slick.min.js"></script>
<link href="//cdn.jsdelivr.net/jquery.slick/1.6.0/slick.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container">
<div class="carousel">
<div><img src="http://fyberproperty.co.uk/wp-content/uploads/2017/04/stairs_one2200.png"></div>
<div><img src="http://fyberproperty.co.uk/wp-content/uploads/2017/04/stairs_two2200.png"></div>
<div><img src="http://fyberproperty.co.uk/wp-content/uploads/2017/04/stairs_one2200.png"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我希望能够列出变化选项值。例如,我有一个 12 英寸、14 英寸和 16 英寸的灯笼。我希望能够获得这些值。我一直在尝试使用 foreach 循环来获取这些值,但我需要一些帮助。这是我的代码;
function test_func(){
global $woocommerce, $product, $post;
// test if product is variable
if( $product->is_type( 'variable' ) ){
$available_variations = $product->get_available_variations();
// var_dump($available_variations);
foreach( $available_variations as $key => $value ){
var_dump( $value['attributes'] ) ;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
array(1) { ["attribute_pa_size"]=> string(4) "12in" } array(1) { ["attribute_pa_size"]=> string(4) "14in" } array(1) { ["attribute_pa_size"]=> string(4) "16in" }
Run Code Online (Sandbox Code Playgroud)
如您所见,我想要的值在那里,但我不知道如何让它们响应它们。
这是我得到的结果,如果我 var_dump() $available_variations;
" ["backorders_allowed"]=> bool(false) ["dimensions"]=> array(3) { ["length"]=> string(4) "11.8" ["width"]=> string(4) " 11.8" …