ERROR: options page not found.我正在开发一个 WordPress 插件,但当我尝试保存更改时,我不断收到错误消息。这是我的设置的页面代码:https://pastebin.com/AsfcqHhe
我已经尝试了很多修复方法,但没有一个有效。
我需要require_once主题中 lib 文件夹中的 php 文件,但仅限于登录页面(也是博客/帖子索引页面)。
当我将require_once代码单独添加到functions.php时,它工作正常,但也会在我需要阻止的所有页面和单个帖子上执行。
当我添加以下条件查询标签时,它们似乎被忽略,并且该文件不包含在主页上。
if ( is_front_page() && is_home() ) {
require_once 'lib/example.php';
}
Run Code Online (Sandbox Code Playgroud)
我缺少什么以及推荐的方法是什么?
注意:这必须添加到主题的functions.php 文件中。
我想添加一个自定义促销内容滑块,并且我想为页面上的每张幻灯片添加 3 个自定义字段:
图片
头条新闻
这段落
但是,我不知道用户想要多少张幻灯片,也许是 2 张,也许是 6 张。
我怎样才能实现这个目标?
之后,我想我只需要一个 for 循环来生成幻灯片。
如果这很重要的话,我有 ACF pro。
我们可以像 WP 样式或脚本串联一样通过Define( 'COMPRESS_CSS', true )压缩我们的 WP 开发主题样式表吗?
我想重写子主题中的函数,该函数在父主题的类中定义。
这是示例代码:
class A extends B{
function __construct(){
$this->add_ajax('sync_post_data', 'need_to_override');
}
//other functions
function need_to_override(){
//function code
}
}
Run Code Online (Sandbox Code Playgroud)
附加信息:
B类扩展了C类,C类是定义的根类add_ajax。
我尝试过的:
其次,我尝试删除 ajax 操作并添加我的自定义操作。它抛出 500 内部服务器错误。
remove_action( 'wp_ajax_sync_post_data', 'need_to_override' );
add_action( 'wp_ajax_sync_post_data', 'custom_function' );
function custom_function(){
//function code with my custom modification
}
Run Code Online (Sandbox Code Playgroud)有什么帮助请...
当我为 WordPress 主题编码时,wp_enqueue_scripts()我注意到了一件事。我看到get_theme_file_uri()工作正常也get_template_directory_uri()工作正常
wp_enqueue_style('fontawesome-css', get_theme_file_uri("/assets/css/font-awesome/css/font-awesome.min.css"), null, "1.0");
Run Code Online (Sandbox Code Playgroud)
和
wp_enqueue_style( 'fontawesome-css', get_template_directory_uri() . '/assets/css/font-awesome/css/font-awesome.min.css', null, '1.0' );
Run Code Online (Sandbox Code Playgroud)
所以我真的很困惑我的代码中将使用哪一个,为什么?
我目前正在创建 WordPress 主题,并偶然发现了一个我不完全理解的问题。我使用以下方法在位置上显示我的导航菜单mega_menu:
wp_nav_menu(array('theme_location' => 'mega_menu'));
Run Code Online (Sandbox Code Playgroud)
这适用于所有正常的帖子和页面。但是,当我位于自定义帖子类型的存档页面上时,menschen菜单不会显示。var_dumping 位置上的导航菜单mega_menu确实返回 WP_Term 对象,但获取项目返回空数组。我不明白这种奇怪的行为,希望有人能帮助我。
我尝试在文件中显示菜单header.php并get_header()在存档页面上调用。
这是我的自定义帖子类型的注册:
function thg_custom_post_type()
{
register_post_type(
'menschen',
array(
'labels' => array(
'name' => __('Menschen'),
'singular_name' => __('Mensch'),
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'taxonomies' => array( 'category' ),
'menu_icon' => 'dashicons-businesswoman',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'custom-fields' ),
'rewrite' => array( 'slug' => 'menschen' ),
)
);
}
add_action('init', 'thg_custom_post_type');
Run Code Online (Sandbox Code Playgroud) 我收到错误:
HTML:
<link rel="stylesheet" href="https://www.domain123.com/wp-content/themes/gogo-theme/css/bootstrap.min.css">
Run Code Online (Sandbox Code Playgroud)
源映射错误:错误:请求失败,状态 404 资源 URL: https: //www.domain123.com/wp-content/themes/gogo-theme/css/bootstrap.min.css 源映射 URL:bootstrap.min.css 。地图
当我将 URL 复制并粘贴到浏览器中时,我可以看到 bootstrap boostrap.min.css 文件。会是错误的原因吗?我如何解决它?
我正在设置一个Wordpress主题,我正在将facebook"Like"按钮集成到每个类别中.
我需要一种方法来获取小写的当前页面URL,因此我可以为所有类别提供几个类似的按钮,每个类别都有不同的URL链接.
目前,当我使用<?php get_permalink( ); ?>或<?php the_permalink( ); ?>类别中的模板,它输出的URL加上第一篇文章,这是不是我想要的目前的永久链接.
我尝试过使用但输出标题的第一个字母是Capped.我需要小写的类别名称,以使URL有效,以便将每个类别页面链接到Facebook.
任何帮助都会很棒.
我疯狂地想弄清楚为什么我很难让WordPress只显示30天以上的帖子而且我真的可以使用第二组眼睛.我正在使用以下代码,但我的网站上没有任何内容.
<?php
// Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
// posts in the last 30 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter( 'posts_where', 'filter_where' );
$the_query = new WP_Query( $query_string );
remove_filter( 'posts_where', 'filter_where' );
?>
<?php if ($the_query->have_posts()) : ?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>"> …Run Code Online (Sandbox Code Playgroud) wordpress ×10
php ×3
css ×2
bootstrap-4 ×1
categories ×1
compression ×1
parent-child ×1
permalinks ×1