我正在完成一个WP主题,我在single.php模板上.我遇到了一些问题,因为我需要访问帖子所在的父类别才能显示某些图像和XML内容.
这是我正在谈论的一个例子.以下是单个帖子的结束URL:
/安德鲁/叶技术-2 /
/andrew/是类别,leaf-art-2是单个帖子.当我在单个帖子上时,我无法single_cat_title();返回当前帖子所在的类别.我正在使用single_cat_title();而不是the_category();因为它显示了类别的字符串值,然后我用它来放置艺术家的图片(这是他们的职位.我对url没有任何用处,我只需要带有类别名称的字符串.
这样做有什么好方法吗?我一直在搜索Wordpress Codex和很多论坛,但还没有找到任何答案.
以下是我的原帖.
我已经设置了一个名为"艺术家"的类别,当我运行时,single_cat_title("", false);我可以获取该类别的字符串值,然后使用它来搜索使用XML的相应艺术家图像.
这在category.php模板页面上工作正常.
问题是,当我实际上在一个具有"艺术家"类别的帖子中时,single_cat_title(); 不会向页面输出任何信息,从而使我无法访问XML数据.
我需要在"艺术家">"样本"帖子中,能够从WP获得该类别.
PS以上类别是使用此设置的许多类别中的一个,这就是我无法对其进行硬编码的原因.
我是WooCommerce的新手.无论如何,我想创建自己的主题,所以我遵循指南并将核心模板文件复制到/ mywordpresstheme/woocommerce /.
一切都很好,我正在编辑模板就好了.
然而,在WooCommerce中钩子和动作的工作方式令我感到困惑,我无法确定生成的HTML的某些部分来自何处.
例如,在content-product.php,有一个获取图像的钩子:
<?php
/*
* woocommerce_before_shop_loop_item_title hook
*
* @hooked woocommerce_show_product_loop_sale_flash - 10
* @hooked woocommerce_template_loop_product_thumbnail - 10
*/
do_action( 'woocommerce_before_shop_loop_item_title' );
?>
Run Code Online (Sandbox Code Playgroud)
但这是什么?它从何而来??在动作名称中是否有任何线索可以找到为编辑它而生成的HTML的位置?
我已经阅读了关于WooCommerce的"钩子和过滤器"的文章,但它没有解释在何种情况下或如何根据案例更改这些内容.
任何帮助将不胜感激.
我是这个系统的新手,我确信我只是在看一些非常明显的东西.
谢谢,Mikey.
wordpress wordpress-theming wordpress-plugin e-commerce woocommerce
我正在创建不同的自定义帖子类型和分类,我想从默认的"帖子"帖子类型中删除"帖子标签"分类.我该怎么做呢?
谢谢.
我是php和wordpress的新手,但是因为有些需要我只能使用wordpress.所以刚开始我读了一个教程并创建了我自己的wordpress主题,当我尝试上传我的主题时,我得到了以下错误:
The package could not be installed. PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature
Run Code Online (Sandbox Code Playgroud)
搜索相同我发现通常导致此类错误的原因是最大可用空间或上传文件大小问题.但是因为我正在使用localhost,所以我认为不是这样.而且我已经提高了upload_max_filesize,post_max_size和memory_limit也.但我仍然得到同样的错误.
我正在使用Wordpress 3.5.2.
我正在创建一个自定义的Wordpress主题,我似乎无法使single.php模板工作.以下是我编写的代码.标题出现但内容没有.任何想法为什么不是?
<?php
/**
* The Template for displaying all single posts.
*/
get_header(); ?>
<div id="content" role="main">
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
<div class="entry">
<?php the_content(); ?>
</div>
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments …Run Code Online (Sandbox Code Playgroud) 我一直在寻找几个星期,我仍然没有找到解决这个问题的正确方法.
我正在写一个Wordpress主题.我有一个名为Works的自定义帖子类型.我想将我的Works存档添加到我的菜单中,并在访问它时突出显示它的帖子.
我可以通过以下链接访问我的存档和帖子
作品档案: /works/
作品单帖: /works/postname/
我的解决方案是archive-works.php使用模板名称(工作档案)命名我的模板文件.然后使用该模板创建一个空页面并将该页面添加到菜单中.这会突出显示菜单中的存档,但不会显示单个帖子.
我可以通过自定义链接和一些javascript轻松解决这个问题,但必须有一个更好,更清洁的方式.
我已经设置了一个名为clientarea的自定义帖子类型,并在管理区域为它设置了几个自定义列 - 自定义列都是自定义元字段,您可以从我的代码中看到.我想按默认下降的"约会日期"排序.
所有列都可以正常工作,并且可以按预期手动排序,但我无法使默认排序顺序起作用.
如果我将默认排序字段更改为标准字段(例如"标题"),它将按预期工作; 当我尝试将自定义列设置为默认排序顺序时,它似乎无法正常工作.订单有效(即我可以在默认情况下使用自定义列在asc和desc之间进行更改),但它不会获取订单,因此会在自定义帖子发布之前恢复为排序.
我错过了什么?
我的代码如下:
add_action( 'manage_posts_custom_column' , 'custom_columns', 10, 2 );
function custom_columns( $column, $post_id ) {
global $wpdb;
switch ( $column ) {
case 'extranet_case_office':
$get_office_ID = get_post_meta( $post_id, 'extranet_case_office', true );
$get_office_name = $wpdb->get_results('SELECT post_title FROM `cn_bf_posts` WHERE `ID` = '.$get_office_ID);
echo $get_office_name[0]->post_title;
break;
case 'extranet_appointment_date':
echo date('d/m/Y',strtotime(get_post_meta( $post_id, 'extranet_appointment_date', true )));
break;
case 'extranet_appointment_type':
echo get_post_meta( $post_id, 'extranet_appointment_type', true );
break;
case 'extranet_insolvency_practioner':
$get_person_ID = get_post_meta( $post_id, 'extranet_insolvency_practioner', true );
$get_person_name = $wpdb->get_results('SELECT …Run Code Online (Sandbox Code Playgroud) 我的标题是调用一个发送电子邮件的javascript文件:
<script type="text/javascript" src="<?php bloginfo('template_directory') ?>/css/effects.js"></script>
Run Code Online (Sandbox Code Playgroud)
但是在这个文件中,我有一个jQuery代码,它调用一个.php文件来实际发送电子邮件:
$.ajax({
type: "POST",
url: "css/sendmail.php",
data: dataString`
Run Code Online (Sandbox Code Playgroud)
但是脚本不起作用,除非url是:
<?php bloginfo('template_directory') ?>/css/sendmail.php
Run Code Online (Sandbox Code Playgroud)
而不仅仅是:
css/sendmail.php
Run Code Online (Sandbox Code Playgroud)
有没有办法在js中包含wordpress模板目录的路径?
其他Wordpress主题开发人员如何利用其压缩输出风格将Sass融入主题开发中?Sass压缩删除所有注释,所以我目前有一个空的style.css与我的主题声明和一个@import调用指南针的缩小的CSS,但这似乎不是最好的解决方案.
有没有人找到解决方法?如果没有,最好的解决方案是什么?
http://codex.wordpress.org/Theme_Development#Theme_Stylesheet
http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#id40
我一直试图用Twig渲染单页wordpress模板,但到目前为止一切都失败了.
{% extends 'layouts/base.twig' %}
{% block content %}
{% for page in pages() %}{{ set_up_page(page) }}
{% include 'content/content-' ~ page.post_name ~ '.twig' %}
{% endfor %}
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
其中一个模板看起来像:
<section id="about" {{ wp.post_class }}>
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading">{{ wp.the_title }}</h2>
<h3 class="section-subheading text-muted">{{ wp.get_post_meta(wp.get_the_ID() , 'st_page_subtitle', true) }}</h3> <!-- To be Changed to subtext for title -->
</div>
</div>
<div class="row">
<div class="col-lg-12">
{{ wp.the_content }}
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
相应的功能:
$wpgetpages = …Run Code Online (Sandbox Code Playgroud) wordpress ×10
php ×5
compass-sass ×1
e-commerce ×1
javascript ×1
jquery ×1
sass ×1
taxonomy ×1
themes ×1
twig ×1
woocommerce ×1