我为wordpress构建了一个非常独特且javascript密集的主题,现在短信不起作用.我没有安装任何插件,所以不是这样.我从使用短代码所需的wordpress模板文件中删除了什么(即:[gallery]).
我理解如何制作短代码,但是当WP将其吐出来展示时,WP如何接受你的帖子并替换"[gallery]"?
编辑:这是我目前正在使用的:
$pagepull = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish' ORDER BY menu_order", ARRAY_A);
$i = 1;
foreach ($pagepull as $single_page){
echo "<div class=\"section\"><ul><li class=\"sub\" id=\"" . $i . "\"><div class=\"insection\">";
echo $single_page['post_content'];
$i++;
// more code that is irrelevant...
// more code that is irrelevant...
// more code that is irrelevant...
}
Run Code Online (Sandbox Code Playgroud) 我有一些在WordPress帖子或页面内工作正常的短代码.有什么我可以添加到functions.php以使短代码在WordPress帖子标题内工作?
尝试从帖子内容中删除图库短代码并保存在变量中以供模板中的其他位置使用.新的Wordpress图库工具非常适合选择他们想要的图像并分配字幕,希望使用它来创建图库,然后将其从前端的内容中拉出来.
所以这个小剪切工作正常,删除画廊和重新应用格式...但我想保存该画廊短代码.
$content = strip_shortcodes( get_the_content() );
$content = apply_filters('the_content', $content);
echo $content;
Run Code Online (Sandbox Code Playgroud)
希望保存短代码,以便将其解析为数组并用于在前端重新创建自定义库设置.我试图保存的这个短代码的一个例子是......
[gallery ids="1079,1073,1074,1075,1078"]
任何建议将不胜感激.
我在我的孩子主题functions.php文件中创建了短代码.该shortcode如下:
function add_login_form() {
if ( is_user_logged_in() )
{
echo 'Witaj zalogowany';
}
else
{
wp_login_form();
}
}
add_shortcode('login_form', 'add_login_form');
Run Code Online (Sandbox Code Playgroud)
我[login_form]在我的网站(测试区域)添加了短代码:http:
//s540141209.domenaklienta.pl/wordpress/konto-klienta/
它被添加到网站后面的文字:"TUTAJPOWINIENBYĆ登录形式LUB NAPIS"WITAJ ZALOGOWANY"!"
它应该在第一个div内: <div class="et_pb_row">
但它显示在页面标题之后.你知道为什么会这样吗?
Thansk提前.但它碰巧显示在网站上的所有内容之前.
这个问题背后的想法在于摘录用avada创建的帖子,但我不能从帖子内容中删除短代码以显示帖子的摘录.
这是我的帖子的例子(使用avada):
[fullwidth background_color="" background_image="" class="" id=""]
[one_full last="yes" spacing="yes" class="" id=""][fusion_text]
Content text ...
[/fusion_text][/one_full][/fullwidth]`
Run Code Online (Sandbox Code Playgroud)
the_excerpt();由于短代码,默认设置不起作用.get_content()返回完整的帖子内容,包括短代码.使用strip_shortcodes()还会删除短代码之间的内容.
所以我的计划是使用模式剥离短代码?并修剪消息以模仿摘录功能.PS:这种模式不起作用.
在首页上使用Woocommerce Recent Products短代码时,我需要排除显示缺货商品.
[recent_products]
Run Code Online (Sandbox Code Playgroud)
是否有可能创建一个类似hide_outofstock="true"或类似的规则来阻止Out of Stock产品展示?
我已经在网上寻找关于如何处理这个问题的想法,而我根本就没有编码器,但通常我能够坦率地解决这个问题.但是,现在我很难过.所有和任何帮助将不胜感激.
我不能通过WooCommerce设置页面隐藏所有缺货产品,因为它们需要在网站的其他区域中可见.
使用"隐藏"而不是"不拉"缺货产品的代码只显示产品显示的空白区域.
需要在库存水平经常变化时动态工作 - 按产品ID手动限制将花费太长时间.
我的代码适用于简单的产品类型,但不适用于 WooCommerce 中的可变产品:
add_shortcode( 'product_sku_div', 'wc_product_sku_div');
function wc_product_sku_div() {
global $product;
return sprintf( '<div class="widget" sp-sku="%s"></div>', $product->get_sku() );
}
Run Code Online (Sandbox Code Playgroud)
如何使其适用于简单产品和可变产品?
我正在制作wordpress插件,我想使用短代码在帖子中插入一些非常庞大的代码.我得到了这个简单的代码来模拟我的问题
function shortcode_fn( $attributes ) {
wanted();
return "unwanted";
}
add_shortcode( 'simplenote', 'shortcode_fn');
function wanted(){
echo "wanted";
}
Run Code Online (Sandbox Code Playgroud)
并发布此内容
start
[simplenote]
end
Run Code Online (Sandbox Code Playgroud)
得出这个结果:
wanted
start
unwanted
end
Run Code Online (Sandbox Code Playgroud)
我希望它在开始和结束之间插入"通缉"文本.我知道最简单的解决办法就是在want()中返回"通缉",但我已经拥有了所有这些功能而且它们非常庞大.有没有从头开始编写所有内容的简单解决方案?
@edit:也许有一些方法可以存储函数中的所有回声而不打印它?
从Wordpress 3.9开始,您可以向functions.php添加一行代码,以告诉Wordpress输出带有更多语义图和figcaption元素的带有标题的图像:
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
Run Code Online (Sandbox Code Playgroud)
这很棒。但是由于某些原因,Wordpress为数字元素添加了宽度的内联样式,这阻止了整个单元的响应。那不是很好 我想向functions.php添加一些代码,以告诉Wordpress不包括行内宽度。
在media.php文件中,我找到了解决我的问题的标题简短代码:
$output = apply_filters( 'img_caption_shortcode', '', $attr, $content );
if ( $output != '' )
return $output;
$atts = shortcode_atts( array(
'id' => '',
'align' => 'alignnone',
'width' => '',
'caption' => '',
'class' => '',
), $attr, 'caption' );
$atts['width'] = (int) $atts['width'];
if ( $atts['width'] < 1 || empty( $atts['caption'] ) )
return $content;
if ( ! empty( $atts['id'] ) )
$atts['id'] = 'id="' …Run Code Online (Sandbox Code Playgroud) 我想制作一个短代码,在短代码中我想要一个文件.当用户在编辑器中编写短代码时.输出将显示所需的文件布局.
我做了一个短代码,但这不起作用,这是我的短信代码:
<?php
function inner_page( $atts, $content = null ){
$return_string = require 'foo/foo_artilces_list.php';
return $return_string;
}
add_action('init', 'register_section_shortcodes');
function register_section_shortcodes(){
add_shortcode('inner_page', 'inner_page');
}
?>
Run Code Online (Sandbox Code Playgroud)
这是我的require文件代码
<?php
/*=========
Template Name: KBE
=========*/
get_header();
?>
<div id="foo_container">
<h1><?php the_title(); ?></h1>
<!--Breadcrum-->
<?php
if(FOO_BREADCRUMBS_SETTING == 1){
?>
<div class="foo_breadcrum">
<?php echo foo_breadcrumbs(); ?>
</div>
<?php
}
?>
<!--/Breadcrum-->
<!--search field-->
<?php
if(FOO_SEARCH_SETTING == 1){
?>
<div class="foo_search_field">
<input name="" type="text" placeholder="Search the knowledgebase..." />
</div>
<?php
}
?>
<!--/search field-->
<!--content-->
<?php …Run Code Online (Sandbox Code Playgroud)