我正在尝试为我的用户提供更改页面上使用的背景图像的功能.
背景图像列表将是一个小数字,不会真正改变.
我想我可以添加一些分类术语...每个背景类型一个...然后在查看页面时将一个类应用于body标签.
这听起来是否可行,如果是这样,我该如何去做呢?
谢谢
山姆
我已经定义了一系列自定义帖子类型(即"PortfolioPage"和"PortfolioGallery").
他们每个人都使用一个名为"艺术家"的自定义分类法.
有没有办法限制最终用户在每个PortfolioPage/PortfolioGallery帖子中输入AT MOST ONE艺术家?
我需要以编程方式为用户通过仪表板创建或更新的每个Wordpress帖子创建一个帖子(或页面)。我加了一个挂钩
add_action( 'publish_post', 'create_details_page');
Run Code Online (Sandbox Code Playgroud)
仅当用户在特定类别中创建或更新帖子,并且在其他类别中创建自动帖子时,才会创建自动帖子。每个帖子仅属于一个类别。创建帖子,如下所示:
$auto_post = array(
'comment_status' => 'closed',
'post_category' => array($category->term_id),
'post_author' => $latest_post[0]->post_author,
'post_type' => 'post',
'post_title' => 'Details for ' . $latest_post[0]->post_title,
'post_parent' => $latest_post[0]->ID,
'post_content' => 'Post content'
);
$auto_post_id = wp_insert_post ( $auto_post, true );
$details = get_post( $auto_post_id );
wp_publish_post( $auto_post_id );
Run Code Online (Sandbox Code Playgroud)
结果不一致:有时我创建了一个自动发布,有时创建了两个,有时却没有。为什么,以及如何精确地插入帖子一次?
要将自动发布作为用户创建的帖子的子代来检索:
$args = array(
'post_type' => 'post',
'post_parent' => $parent_post_id,
'post_status' => 'publish'
/* 'category_name' => array('Auto Post Category') */
);
$children = get_posts( $args );
Run Code Online (Sandbox Code Playgroud)
添加category_name参数将导致根本不检索任何子帖子。如果没有category参数,则返回子帖子,并且它们具有category set属性。但是,似乎未检索到完整列表,并且每次运行的结果都不同。
如果随后从仪表板编辑了自动发布的内容,则上面的查询不会返回此编辑过的帖子。为什么? …
我正在使用WP PageNavi插件进行分页.关闭WP PageNavi时,如果没有将taxonomy-portflio-category.php页面分页,这个问题也是一个问题.
我有一段时间在主页和页面模板页面上进行分页,但我确实让它们起作用.这是他们的代码:
page-home.php(在名为"Home"的静态首页上用作页面模板)
$paged = 1;
if ( get_query_var('paged') ) $paged = get_query_var('paged');
if ( get_query_var('page') ) $paged = get_query_var('page');
$i = 0;
$loop = new WP_Query( array( 'post_type' => 'portfolio', 'paged' => $paged, 'posts_per_page' => 24 ) );
while ( $loop->have_posts() ) : $loop->the_post();
// output
$i++; endwhile;
if ( function_exists( 'wp_pagenavi' ) ) {
wp_pagenavi( array( 'query' => $loop ) );
wp_reset_postdata();
}
Run Code Online (Sandbox Code Playgroud)
分页工作!
page-portfolio.php(在页面上用作页面模板,称为"工作")
$i = 0;
$loop = new WP_Query( array( 'post_type' …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Wordpress中设置包含自定义帖子类型和自定义分类的存档页面.
我创建了自定义帖子类型:"package"和自定义分类:"software".我的问题是,当我尝试查看localhost:8888/software/aperture时,我得到了类型包的所有帖子,而不仅仅是选择了自定义分类光圈的帖子.我使用以下代码:
<?php
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
?>
<h1><?php echo $term->name;?> Presets</h1>
<div class="intro2">
<p>
<?php echo $term->description;?>
</p>
</div>
<?php query_posts('post_type=package'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- Product Start -->
<div class="product">
<div class="product_top"></div>
<div class="product_content">
<div class="product_image">
<a href="<?php the_permalink()?>">
<?php echo get_the_post_thumbnail( $id, $size, $attr ); ?>
</div>
<a href="<?php the_permalink()?>" class="title"><?php the_title()?></a>
<?php the_excerpt()?>
<div class="theprice">
<?php
$price = get_post_meta($post->ID, …Run Code Online (Sandbox Code Playgroud) 我需要以编程方式创建Drupal 7网站中使用的标记列表.我正在浏览api /函数,但找不到像"get_list_of_terms()"这样的东西:-)
我该怎么办?谢谢!J.
如何只使用分类标本获取分类标识或名称?
我想我正在寻找相当于get_term_by()但是对于分类法.
编辑:我必须指定我正在尝试获取WooCommerce产品属性的税号.
谢谢
我正在使用:
我注册自定义分类(目录)
<?php
add_action('init', 'pca_register_taxonomy', 0);
function pca_register_taxonomy()
{
register_taxonomy('catalog', null,
array(
'label' => __('Catalogs', __),
'labels' => array(
'name' => __('Catalogs', __),
'singular_name' => __('Catalog', __),
'search_items' => __('Search Catalogs', __),
'popular_items' => __('Popular Catalogs', __),
'all_items' => __('All Catalogs', __),
'parent_item' => __('Parent Catalog', __),
'parent_item_colon' => __('Parent Catalog', __),
'edit_item' => __('Edit Catalog', __),
'update_item' => __('Update Catalog', __),
'add_new_item' => __('Add New Catalog', __),
'new_item_name' => __('New Catalog Name', __), …Run Code Online (Sandbox Code Playgroud) 我在我的博客上设置了一个自定义帖子类型,并为分类法设置了一个特殊页面。在分类页面上,我收到以下错误。谁能给我一些有关如何解决此错误的提示?
该页面加载正常,并按我的预期工作。但是,如果我将调试设置为 true,则会出现以下错误。我想解决这个问题。我粘贴了循环中的成本,该循环在页面上以不同的标准运行了两次。
Notice: Trying to get property of non-object in /home3/ans/public_html/wp-includes/post-template.php on line 29
Run Code Online (Sandbox Code Playgroud)
代码:
<?php
query_single('dealers', 'publish', '1', $taxtype, $value);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$address=get_post_meta($post->ID, 'wpcf-street_address', TRUE);
$city=get_post_meta($post->ID, 'wpcf-city', TRUE);
$state=get_post_meta($post->ID, 'wpcf-state_abbreviation', TRUE);
$zip=get_post_meta($post->ID, 'wpcf-zip_code', TRUE);
$phone=get_post_meta($post->ID, 'wpcf-phone_number', TRUE);
$paid=get_post_meta($post->ID, 'wpcf-paid', TRUE);
$post_id=get_the_ID();
get_each_dealer_brand($post_id);?>
<?php
echo "<ul class=\"ullisting\">";
if($paid==1)
{
echo "<li><p class=\"plisting\"><strong><a href=\"";the_permalink(); echo "\">";the_title();echo "</a></strong></p></li>";
echo "<li><p class=\"plisting\">$address | $city, $state $zip</p></li>";
echo "<li><p class=\"plisting\">P: $phone</p></li>";
echo …Run Code Online (Sandbox Code Playgroud) 我正在创建一个 WordPress 站点,以使用自定义帖子类型和自定义分层分类法显示项目目录。我想保持简单并处理单个存档页面中的项目,但我需要帮助如何确定当前显示的分类级别。基本上,我需要以下功能:
if ($current_term_level = 0) {
// show first drop-down
} else if ($current_term_level = 1) {
// show second drop-down
} else {
// show third drop-down
}
Run Code Online (Sandbox Code Playgroud)
有人可以解释如何$current_term_level输出适当的值吗?
taxonomy ×10
wordpress ×8
php ×3
drupal ×2
pagination ×2
background ×1
drupal-7 ×1
parent-child ×1
tags ×1