标签: wordpress-theming

显示 WordPress 上帖子的浏览次数

我正在开发一个 WordPress,并使用插件 WordPress 热门帖子,并面临这个问题。

如何在博客的类别列表页面或索引页面上显示访问者查看页面的次数。此信息已经存在,插件正在使用该信息在侧边栏中显示相同的信息,不确定如何使用相同的插件数据在博客页面上显示页面浏览量。

我试图找到这个,但没有得到我想要的。

请建议如何做到这一点?

我使用的插件是http://wordpress.org/extend/plugins/wordpress-popular-posts/

wordpress wordpress-theming

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

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

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

wordpress wordpress-theming

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

在 WordPress 中隐藏“发布的帖子。查看帖子”管理通知

有谁知道如何在管理员的 WordPress 网站上发布帖子后隐藏出现的帖子发布消息。

我已经看到这个例子向除管理员之外的所有人隐藏更新可用消息,但我不确定需要添加什么来删除保存消息:

function hide_update_notice_to_all_but_admin_users() 
{
    if (!current_user_can('update_core')) {
        remove_action( 'admin_notices', 'update_nag', 3 );
    }
}
add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 );
Run Code Online (Sandbox Code Playgroud)

我需要删除常规帖子和自定义帖子类型上的消息。据我所知,这应该只是替换的情况,'update_nag'但我不确定用什么替换它。

谢谢

php wordpress wordpress-theming

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

如何设置类别列表限制?

我是显示帖子类别子列表.列表显示所有我需要显示只有6(孩子)帮助我们...

ex:menu(父)list1(child)list2(child)list3(child)list4(child)list5(child)list6(child)list7(child)list8(child)

<?php $article_categories = get_categories(array(
                                    'child_of' => get_category_by_slug('work')->term_id
                            ));
    $talentChildren = get_categories(array('child_of' => get_category_by_slug('talent')->term_id));


 ?>
    <?php if ( have_posts()) : ?>
        <?php $talent_Children = array($talentChildren[0]); ?>
        <?php foreach($talent_Children as $talent): ?>
        <?php
        $talentSubChildren = new WP_Query();
        $talentSubChildren->query(array('category_name' => $talent->slug));
        ?>
        <h2><a href="<?php the_permalink() ?>talent/directors/"><?php echo $talent->name; ?></a></h2>
        <ul>
        <?php while ($talentSubChildren->have_posts()) : $talentSubChildren->the_post(); ?>
        <li>
        <h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
        </h4>
        </li>
        <?php endwhile; ?>
        </ul>
        <?php endforeach; ?>
        <?php endif; ?>
        </div>
Run Code Online (Sandbox Code Playgroud)

php wordpress wordpress-theming

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

WordPress 短代码参数

有没有办法获取WordPress简码中的所有参数?

例如,

function bartag_func( $atts ) {
    $a = shortcode_atts(
             array(
                 'foo' => 'something',
                 'bar' => 'something else',
             ),
             $atts);

    return "foo = {$a['foo']}";
}
add_shortcode('bartag', 'bartag_func');
Run Code Online (Sandbox Code Playgroud)

[bartag]是简码。

有没有办法知道 的值shortcode_atts或 的值foo bar等?

有没有办法获取 中的所有变量值bartag_func

wordpress wordpress-theming

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

WC_Order 中的产品 ID 返回空 - WooComerce

我使用的是 WooComerce 插件版本 2.6.11,WordPress 版本是 4.7.2。我正在尝试使用订单的产品元数据 (order_id=273) 获取所有产品。我试过如下。但$item['product_id']返回空。什么都没有返回。

    function custom_get_order_details($order_id){
      global $woocommerce; 


      // for test im using $order_id = 273
      $order = new WC_Order( $order_id );

      foreach ( $order->get_items() as $item_id => $item ){

          print_r($item_id);
          echo $product_id = wc_get_order_item_meta($item_id, '_product_id', true);
          echo "<br>test_30<br>";
          echo $variation_id = wc_get_order_item_meta($item_id, '_variation_id', true);
          echo $quantity = wc_get_order_item_meta($item_id, '_qty', true);

      }
      //$curl = curl_init();
      //curl post here
    }
    add_action( 'woocommerce_payment_complete', 'custom_get_order_details', 10, 1 );
Run Code Online (Sandbox Code Playgroud)

如果我打印$item内部 for 循环。它打印

array(4) { ["name"]=> string(4) …
Run Code Online (Sandbox Code Playgroud)

php wordpress product wordpress-theming woocommerce

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

将 Javascript 插入 WordPress 管理页脚

我需要在所有 WordPress 管理页面(后端)上添加 Livechat 小部件。

Livechat JavaScript 代码是这样的:

<!-- Start of LiveChat (www.livechatinc.com) code -->
<script type="text/javascript">
window.__lc = window.__lc || {};
window.__lc.license = 12345678;
(function() {
  var lc = document.createElement('script'); lc.type = 'text/javascript'; lc.async = true;
  lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(lc, s);
})();
</script>
<noscript>
<a href="https://www.livechatinc.com/chat-with/10437202/" rel="nofollow">Chat with us</a>,
powered by <a href="https://www.livechatinc.com/?welcome" rel="noopener nofollow" target="_blank">LiveChat</a>
</noscript>
<!-- End of LiveChat code -->
Run Code Online (Sandbox Code Playgroud)

Livechat 有一个可以在前端页面上进行聊天的插件。我实际上想将此代码添加到 WordPress 后端的每个页面。 …

javascript wordpress wordpress-theming custom-wordpress-pages wordpress-admin

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

如何在 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万
查看次数

purgecss 无法识别条件类

所以我将 TailwindCSS 用于我正在开发的 WP 主题。

我在创建生产级主题文件时遇到了一个问题,因为根据我对问题的理解,purgecss 无法识别模板部件上使用的条件类。例如,假设我创建了一个名为“business-card.php”的模板部分,我在其中传递了一个变量type(使用set_query_var/ get_query_var):

页面-about.php

set_query_var('type', 'A');
get_template_part('template-parts/content/business', 'card');

set_query_var('type', 'B');
get_template_part('template-parts/content/business', 'card');
Run Code Online (Sandbox Code Playgroud)

企业卡.php

$type = get_query_var('type')
<div class="<?php echo type == 'A' ? 'text-color-A' : 'text-color-B' ?>">
--- insert some content here ---
</div>
Run Code Online (Sandbox Code Playgroud)

所以会有两个 div,一个有一个text-color-A类,另一个有一个text-color-B,两者都是使用配置文件创建的(而不是包含在基本的顺风主题中)。这在开发中很好——因为 tailwind 实际上从配置文件创建了实用程序颜色类。但是出于某种原因,当它在生产中(即清除和缩小)时,它没有那些实用程序类——它们只在模板部分作为条件类使用(而不是在任何其他文件中)。

wordpress-theming tailwind-css css-purge

4
推荐指数
3
解决办法
4586
查看次数

获取产品变体父产品

如何获取变体父产品 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
查看次数