标签: wordpress-theming

如何在图像附件页面上显示附加到帖子的图像数量?

我使用图像附件页面以幻灯片形式的影响逐个显示附加到帖子的图像.我希望能够显示附加到父帖子的图像总数以及在任何给定附件页面上显示的特定图像的编号,以便您看到图片和单词"Image 3 of 15",例如.

更新... 我能够使用此代码获取要显示的总数:

<?php 
  global $post;
  $attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) );
  $count = count( $attachments );
  echo $count; 
?>
Run Code Online (Sandbox Code Playgroud)

我仍然无法弄清楚如何显示当前图像的数量.
有人有什么建议吗?

更新2 ...

格林妮的回答让我几乎在那里,但它一次输出所有数字:

"Image 1 of 8Image 2 of 8Image 3 of 8Image 4 of 8Image 5 of 8Image 6 of 8Image 7 of 8Image 8 of 8"

这是我使用的代码:

global $post;
$attachments = get_children( …
Run Code Online (Sandbox Code Playgroud)

wordpress wordpress-theming

5
推荐指数
1
解决办法
6190
查看次数

自动将WordPress帖子内容拆分为3列?

我目前正在使用本教程中的以下代码自动将WordPress帖子内容拆分为2列.但是,如何将此代码更改为输出3列而不是仅2?

functions.php代码:

function content_split($text, $separator = '<hr/>', $start = false ) {

if ( $start === false) {
$start = strlen($text) / 2;
}

$lastSpace = false;
$split = substr($text, 0, $start - 1);

// if the text is split at a good breaking point already.
if (in_array(substr($text, $start - 1, 1), array(' ', '.', '!', '?'))) {

$split .= substr($text, $start, 1);
// Calculate when we should start the split
$trueStart = strlen($split);

// find a good …
Run Code Online (Sandbox Code Playgroud)

php wordpress function wordpress-theming multiple-columns

5
推荐指数
1
解决办法
1641
查看次数

如何将自定义HTML代码放在wordpress网站的标题中

这是我的网站,我需要输入html代码,以使标题选项形式功能http://emmacombes.com/

但我不清楚我可以在哪里粘贴标题的HTML代码.使用Wordpress主题 - 填充

谢谢

html wordpress wordpress-theming

5
推荐指数
1
解决办法
5万
查看次数

定制器颜色方案不通过颜色

我多年没有使用WordPress,Customizer对我来说是全新的,我相信我已经搞砸了默认的配色方案值并且可以真正使用一些帮助.我拿了一个HTML网站,并在它的基础文件结构的TwentySixteen主题的顶部构建它,以及绑定到一些较新的功能(对我来说是新的).我Customizer.php按照我需要的方式更改了文件以进行CSS更改,但它不再采用颜色方案选项并将它们传递出去,所以我的主题目前基本上没有颜色.我继续透过它来看看我搞砸了什么,但如果有人能指出我解决这个问题的方向会很棒.

这是我的Customizer.php文件的pastebin.

http://pastebin.com/gmK4KmGX

虽然通常我会尝试提供更多我试图修复它的细节,但此时我完全迷失了,只是拉起了Codex开始找出一些希望在某个地方休息的新事物.

任何帮助将不胜感激.

编辑:如果我手动选择颜色并保存它,它可以工作.只是不使用Color Schemes和默认配色方案.

编辑2:还注意到它在自定义程序中进行编辑时不会自动更新网站(如选择新颜色),我现在完全陷入困境,不得不错过一些非常简单的东西.要对此开始赏金.

wordpress wordpress-theming

5
推荐指数
1
解决办法
872
查看次数

REST API在自定义帖子中不起作用

我已经在function.php文件中创建了自定义帖子,对我来说很好。当我通过WordPress REST API调用自定义帖子数据时,它向我显示了浏览器中的错误。

以下是在浏览器中显示给我的错误。

code    "rest_no_route"
message "No route was found matching the URL and request method"
data    
status  404
Run Code Online (Sandbox Code Playgroud)

但是rest API适用于WordPress中存在的默认帖子。

wordpress wordpress-theming wordpress-rest-api

5
推荐指数
1
解决办法
675
查看次数

如何将YouTube视频取消静音(并关闭自动播放)二十七年?

在YouTube上一个演讲,我想用它作为我二十一岁儿童主题网站的标题电影.我希望它有声音,没有自动播放.(在Youtube上观看,视频声音完好无损.)

关于[关于自动播放的这个问题],我发布了一个https://www.youtube.com/watch?v=1dYAYBNU6qM&autoplay=0的视频网址.该行为似乎没有改变.它会立即启动,但声音会静音.

如果用户点击"播放"按钮,如果二十七岁的话,我是否可以选择开始暂停并开始播放的媒体文件?

谢谢,

wordpress wordpress-theming child-theming twentyseventeen

5
推荐指数
1
解决办法
2364
查看次数

WP主题定制器 - 选项顺序

我遇到了主题定制器的问题.我的代码是:

function candyfloss_theme_customizer( $wp_customize ) { 
    class Heading extends WP_Customize_Control {
    public $type = 'heading';

    public function render_content() {
        ?>
        <label>
        <span class="customize-control-title" style="border-bottom: 1px dashed #666;"><strong><?php echo esc_html( $this->label ); ?></strong></span>            
        </label>
        <?php
    }
}
$wp_customize->add_setting('products_heading', array(
    'default',
) );
$wp_customize->add_control(new Heading ($wp_customize, 'products_heading', array(
    'label' => __('Home - products section'),
    'type' => 'heading',
    'section' => 'home',        
) ) );

$wp_customize->add_setting('candyfloss_product_first', array(
    'deafault',
) );
$wp_customize->add_control('candyfloss_product_first', array(
    'label' => __('First product page'),
    'type' => 'dropdown-pages',
    'section' => 'home',        
) …
Run Code Online (Sandbox Code Playgroud)

wordpress wordpress-theming

4
推荐指数
1
解决办法
978
查看次数

如何从 WordPress 管理面板的添加用户页面中删除网站字段?

现在我不可能从 WordPress 仪表板添加用户页面中删除网站字段。有人请建议一些吗?

wordpress wordpress-theming

4
推荐指数
1
解决办法
4970
查看次数

如何在 WooCommerce 中创建有效的自定义产品查询?

我在创建自己的自定义 WooCommerce 产品循环时遇到困难。

在此过程中,我遇到了一些问题,如果能够得到解答,那将非常有帮助。

我目前正在使用这段代码:

ARCHIVE-PRODUCT.PHP(移至子主题 -> woocommerce/archive-product.php):

<?php
/**
 * @see https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates
 * @version 3.4.0
 */

defined( 'ABSPATH' ) || exit;

get_header();

$display_count = $atts['per_page'];
echo $display_count; // NO value - How do I access this?
$page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
echo $page; // returns 1 - CORRECT;
$offset = ( $page - 1 ) * $display_count;
echo $offset; // returns 0 - CORRECT;
$args = array(
    'post_type'             => …
Run Code Online (Sandbox Code Playgroud)

php wordpress wordpress-theming woocommerce

4
推荐指数
1
解决办法
1万
查看次数

获取产品变体父产品

如何获取变体父产品 ID。

示例:我的产品 ID 为 35,该产品有两种颜色 - 红色 (ID 351)、黑色 (ID 352)

我的代码: $product = wc_get_product(get_the_ID()); //get_the_ID() is ID 351 and I need this parent ID 35

wordpress wordpress-theming woocommerce hook-woocommerce

4
推荐指数
1
解决办法
2675
查看次数