我有一个html结构,需要自定义wp_nav_menu代码.
这是我需要生成的html:
<ul class="main-nav">
<li class="item">
<a href="http://example.com/?p=123" class="title">Title</a>
<a href="http://example.com/?p=123" class="desc">Description</a>
<ul class="sub-menu">
<li class="item">
<a href="http://example.com/?p=123" class="title">Title</a>
<a href="http://example.com/?p=123" class="desc">Description</a>
</li>
</ul>
</li>
<li class="item">
<a href="http://example.com/?p=123" class="title">Title</a>
<a href="http://example.com/?p=123" class="desc">Description</a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我目前正在使用wp_get_nav_menu_items我的菜单中的所有项目作为数组.
现在我可以使用以下代码在没有子菜单的情况下生成上面的html :
<?php
$menu_name = 'main-nav';
$locations = get_nav_menu_locations()
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );
foreach ( $menuitems as $item ):
$id = get_post_meta( $item->ID, '_menu_item_object_id', true …Run Code Online (Sandbox Code Playgroud) 我想从http://example.com/project_name/abc_15_11_02_3/获取"abc_15_11_02_3" .我怎样才能做到这一点?
我遇到了这个错误.我不知道处理这件事.
无法修改标题信息 - 已在/home/ben213/public_html/wp-includes/pluggable.php中发送的标题(由/home/ben213/public_html/wp-content/themes/Bendaggers/functions.php:9开始输出) 934行
我的Functions.php文件行#9是:
<?php if(function_exists('register_sidebar'))register_sidebar();?>
Run Code Online (Sandbox Code Playgroud)
而我的pluggable.php#934是
function wp_redirect($location, $status = 302) {
global $is_IIS;
$location = apply_filters('wp_redirect', $location, $status);
$status = apply_filters('wp_redirect_status', $status, $location);
if ( !$location ) // allows the wp_redirect filter to cancel a redirect
return false;
$location = wp_sanitize_redirect($location);
if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
status_header($status); // This causes problems on IIS and some FastCGI setups
header("Location: $location", true, $status);}
endif;
Run Code Online (Sandbox Code Playgroud)
因为我不是程序员,所以我很难搞清楚这一点.什么似乎是错的?请帮助我...
产品随机显示的客户网站存在问题
"该产品目前无货,无法使用."
问题是我们没有开启库存跟踪,所有产品都应该一直有库存.
当我进入WordPress管理员并单击产品的更新按钮(不更改任何内容),然后消息消失,"添加到购物车"按钮显示应该.不幸的是,这个问题在未来会重复出现并修复它我必须再次更新产品(同时点击WooCommerce设置中的更新暂时解决了这个问题).
我需要找到一种永久解决这个问题的方法,这样它就不会自行恢复.
网站详情:
我试过的
_manage_stock并将其设置为no(在我们的一些工作产品中观察到)0(如我们所拥有的一些工作产品中所观察到的)$available_variations变量variable.php和
class-wc-ajax.php和class-wc-product-variable.php.在调试时,我注意到在使用$available_variations变量的产品中包含2个填充了产品信息的数组,但是在没有产品信息的产品上,它是一个空数组(导致缺货信息显示为服务状态variable.php).单击更新按钮然后跟踪变量可正确显示信息.
老实说,在这一点上,我很茫然.我认为这个问题出现在任何一个类中,但我无法分辨.
还有其他人有这个问题吗?任何解决这个问题的方法,所以我不必为这个客户端不断更新产品.
链接到缺货的产品(截至发布时)http://highlandsministriesonline.org/product/basement-tapes/resentment-in-the-church-135/
链接到正确显示的产品http://highlandsministriesonline.org/product/basement-tapes/bt0111-church-at-corinth-i/
错误日志 我在产品变体类中添加了错误日志.下面是结果:
对于具有"缺货"消息的产品,日志中不显示任何内容.
正常运行的产品示例:
WC_Product_Variation Object
(
[variation_id] => 1310
[parent] => WC_Product_Variable Object
(
[children] => Array
(
[0] => 1311
[1] => 1310
)
[total_stock] =>
[id] => 1308
[post] => …Run Code Online (Sandbox Code Playgroud) 我使用facebook开发了一个用于社交登录的wordpress插件.我正在使用facebook图形API /me来检索用户详细信息,在安装facebook登录插件时我的问题是某些网站我只是获取用户ID和名称
Array
(
[name] => John doe
[id] => 398463877009801
)
Run Code Online (Sandbox Code Playgroud)
但同样的代码也适用于某些网站.
Array
(
[id] => 398463877009801
[email] => something@gmail.com
[first_name] => John
[gender] => male
[last_name] => Doe
[link] => https://www.facebook.com/app_scoped_user_id/398463877009801/
[locale] => en_US
[name] => John Doe
[timezone] => 5.45
[updated_time] => 2015-05-03T11:24:16+0000
[verified] => 1
)
Run Code Online (Sandbox Code Playgroud)
对于只获得名称和ID的网站,可能存在错误的可能性?
我有以下功能.Wordpress功能,但这确实是一个PHP问题.他们$term根据artist_lastname每个对象元数据中的属性对对象进行排序.
我想$meta在第一个函数中传入一个字符串.这将允许我重用此代码,因为我可以将其应用于各种元数据属性.
但我不知道如何将额外的参数传递给usort回调.我试图制作一个JS风格的匿名函数,但服务器上的PHP版本太旧了,引发了语法错误.
任何帮助 - 或者向手册右上角推 - 都非常感激.谢谢!
function sort_by_term_meta($terms, $meta)
{
usort($terms,"term_meta_cmp");
}
function term_meta_cmp( $a, $b )
{
$name_a = get_term_meta($a->term_id, 'artist_lastname', true);
$name_b = get_term_meta($b->term_id, 'artist_lastname', true);
return strcmp($name_a, $name_b);
}
Run Code Online (Sandbox Code Playgroud) 我想知道使用PHP的访客国家并将其显示在WordPress页面中.但是当我在WordPress页面或Post中添加PHP代码时,它会给我错误.我们如何在Wordpress Page和Post中添加PHP代码.
<?PHP
try{
function visitor_country()
{
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
$result = "Unknown";
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
$ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
if($ip_data && $ip_data->geoplugin_countryName != null)
{
$result = array('ip'=>$ip,
'continentCode'=>$ip_data->geoplugin_continentCode,
'countryCode'=>$ip_data->geoplugin_countryCode,
'countryName'=>$ip_data->geoplugin_countryName,
);
}
return $result;
}
$visitor_details= visitor_country(); // Output Country name [Ex: United States]
$country=$visitor_details['countryName'];
Run Code Online (Sandbox Code Playgroud) 我创建了一个用户的github页面.
现在,假设我在repo的根目录下有一个Image文件 Images/Emoticons/Cool.png
我尝试在我的主Index.html文件中插入该图像.
我写 -
- <img src="\images\emoticons\cool.png"> 没有任何显示在线和离线
- <img src="images\emoticons\cool.png">没有任何东西出现在网上,但我可以看到图像离线
- <img src="..\images\emoticons\cool.png">没有任何显示在线和离线
应该做什么?
我已经看过旧的问题,并尝试了许多不同的方法,似乎是这样做的.我最接近的工作就是这里:如何在自定义WP_Query Ajax上实现分页
我已经尝试了一切,它只是不起作用.页面上绝对没有任何变化.如果你检查加载更多按钮并单击它,jquery正在进行加载更多按钮操作,因为它改变<a id="more_posts">Load More</a>了<a id="more_posts" disables="disabled">Load More</a>,即使这对我来说似乎也没有.它没有添加帖子,我想我错过了一些简单的东西,但对于我的生活,我无法解决它.
我的模板文件中的代码是:
<div id="ajax-posts" class="row">
<?php
$postsPerPage = 3;
$args = [
'post_type' => 'post',
'posts_per_page' => $postsPerPage,
'cat' => 1
];
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post(); ?>
<div class="small-12 large-4 columns">
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
</div>
<?php
endwhile;
echo '<a id="more_posts">Load More</a>';
wp_reset_postdata();
?>
</div>
Run Code Online (Sandbox Code Playgroud)
我的函数文件中的代码是:
function more_post_ajax(){
$offset = $_POST["offset"];
$ppp = $_POST["ppp"];
header("Content-Type: text/html");
$args = [
'suppress_filters' => true, …Run Code Online (Sandbox Code Playgroud) 我需要创建一个WordPress插件,在单击管理面板中的按钮时调用PHP函数.我一直在寻找编写基本WordPress插件和添加管理面板的教程,但我仍然不明白如何在我的插件中将按钮注册到特定功能.
这是我到目前为止所拥有的:
/*
Plugin Name:
Plugin URI:
Description:
Author:
Version: 1.0
Author URI:
*/
add_action('admin_menu', 'wc_plugin_menu');
function wc_plugin_menu(){
add_management_page('Title', 'MenuTitle', 'manage_options', 'wc-admin-menu', 'wc_plugin_options');
}
function wc_plugin_options(){
if (!current_user_can('manage_options')) {
wp_die( __('You do not have sufficient permissions to access this page.') );
}
echo '<div class="wrap">';
echo '<button>Call Function!</button>'; //add some type of hook to call function
echo '</div>';
}
function button_function()
{
//do some stuff
}
?>
Run Code Online (Sandbox Code Playgroud)