自定义后期存档不起作用

时间:2017-09-28 作者:Harshad Gole

我已经为我的自定义帖子创建了WordPress插件。我已经尝试了所有存档解决方案,我在Youtube和StackExchange上找到了这些解决方案,但都不起作用。

我已经多次刷新permalink并尝试了其他选项。

localhost/westernlogan/articles/ - 此存档链接出现错误(哎呀!找不到该页。)(甚至我也尝试过删除结束斜杠的链接)

localhost/westernlogan/articles/what-is-computer-aided-design-cad/ - 此链接工作正常

archive-articles.php - 存档页面名称

<?php
/*
Plugin Name: Westernlogan Dashboard
Plugin URI: http://www.westernlogan.com/
Description: This is not just a Dashboard, it symbolizes the hope and 
enthusiasm of an entire generation summed up in two words sung most famously 
by Westernlogan.
Author: Harshad
Version: 1.0
Author: Westernlogan
Author URI: http://www.westernlogan.com/
*/

add_action(\'init\', \'articles_post_type\');
add_action(\'init\', \'custom_taxonomy\');

function articles_post_type() {
$args = array(
        \'labels\'    => array(
            \'name\'               => _x( \'Articles\', \'lr_article\' ),
            \'singular_name\'      => _x( \'Article\', \'lr_article\' ),
            \'menu_name\'          => _x( \'Articles\', \'lr_article\' ),
            \'name_admin_bar\'     => _x( \'Article\', \'lr_article\' ),
            \'add_new\'            => _x( \'Add New\', \'lr_article\' ),
            \'add_new_item\'       => __( \'Add New article\', \'lr_article\' ),
            \'new_item\'           => __( \'New article\', \'lr_article\' ),
            \'edit_item\'          => __( \'Edit article\', \'lr_article\' ),
            \'view_item\'          => __( \'View article\', \'lr_article\' ),
            \'all_items\'          => __( \'All articles\', \'lr_article\' ),
            \'search_items\'       => __( \'Search articles\', \'lr_article\' ),
            \'parent_item_colon\'  => __( \'Parent articles:\', \'lr_article\' ),
            \'not_found\'          => __( \'No articles found.\', \'lr_article\' ),
            \'not_found_in_trash\' => __( \'No articles found in Trash.\', \'lr_article\' )
        ),
        \'query_var\' => \'Articles\',
        \'rewrite\'   => array(
            \'slug\'          => \'articles\',
            \'with_front\'    => false
        ),
        \'public\'        => true,
        // \'menu_position\' => 5,
        \'menu_icon\'     => plugin_dir_url(__FILE__) . \'av-logo.png\',
        \'supports\'      => array(
            \'title\',
            \'editor\',
            \'thumbnail\',
            \'excerpt\'
        )
    );
    flush_rewrite_rules();

    register_post_type(\'articles\', $args);}

function custom_taxonomy() {

    $taxonomies = array(
        \'hierarchical\' => true,
        \'query_var\' => \'Articles_category\',
        \'rewrite\' => array(
            \'slug\' => \'article-category\',
        ),
        \'labels\' => array(
            \'name\' => \'Articles Category\',
            \'singular_name\' => \'Articles Category\',
            \'edit_item\' => \'Edit Articles Category\',
            \'update_item\' => \'Update Articles Category\',
            \'add_new_item\' => \'Add Articles Category\',
            \'new_item_name\' => \'Add New Articles Category\',
            \'all_items\' => \'All Articles Category\',
            \'search_items\' => \'Search Articles Category\',
            \'popular_items\' => \'Popular Articles Category\',
            \'separate_items_with_comments\' => \'Separate articles Category with Commas\',
            \'add_or_remove_items\' => \'Add or Remove articles Category\',
            \'choose_from_most_used\' => \'Choose from most used articles Category\'));

    register_taxonomy(\'articles_category\', array(\'articles\'), $taxonomies);}
这是我的。htaaccess设置(如果需要)

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /westernlogan/
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /westernlogan/index.php [L]
</IfModule>

# END WordPress

# WP Maximum Execution Time Exceeded
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_input_time 300

</IfModule>

1 个回复
最合适的回答,由SO网友:rudtek 整理而成

为什么不尝试添加:

    \'has_archive\'        => true,
到您的代码?

因此,请替换此行:

    \'public\'        => true,
使用此选项:

    \'public\'        => true,
    \'has_archive\'        => true,
然后通过访问设置/永久链接刷新永久链接。

结束

相关推荐

Virtual Pages plugins

我很难让插件正常工作Virtual Pages (WordPress插件可简化虚拟页面的创建)我确实进行了编辑,根据查询创建了一个循环。add_action( \'gm_virtual_pages\', function( $controller ) { /* Creating virtuals pages for companies */ $args = array( \'post_type\' => array(\'companies\',), \'post_status\'

自定义后期存档不起作用 - 小码农CODE - 行之有效找到问题解决它

自定义后期存档不起作用

时间:2017-09-28 作者:Harshad Gole

我已经为我的自定义帖子创建了WordPress插件。我已经尝试了所有存档解决方案,我在Youtube和StackExchange上找到了这些解决方案,但都不起作用。

我已经多次刷新permalink并尝试了其他选项。

localhost/westernlogan/articles/ - 此存档链接出现错误(哎呀!找不到该页。)(甚至我也尝试过删除结束斜杠的链接)

localhost/westernlogan/articles/what-is-computer-aided-design-cad/ - 此链接工作正常

archive-articles.php - 存档页面名称

<?php
/*
Plugin Name: Westernlogan Dashboard
Plugin URI: http://www.westernlogan.com/
Description: This is not just a Dashboard, it symbolizes the hope and 
enthusiasm of an entire generation summed up in two words sung most famously 
by Westernlogan.
Author: Harshad
Version: 1.0
Author: Westernlogan
Author URI: http://www.westernlogan.com/
*/

add_action(\'init\', \'articles_post_type\');
add_action(\'init\', \'custom_taxonomy\');

function articles_post_type() {
$args = array(
        \'labels\'    => array(
            \'name\'               => _x( \'Articles\', \'lr_article\' ),
            \'singular_name\'      => _x( \'Article\', \'lr_article\' ),
            \'menu_name\'          => _x( \'Articles\', \'lr_article\' ),
            \'name_admin_bar\'     => _x( \'Article\', \'lr_article\' ),
            \'add_new\'            => _x( \'Add New\', \'lr_article\' ),
            \'add_new_item\'       => __( \'Add New article\', \'lr_article\' ),
            \'new_item\'           => __( \'New article\', \'lr_article\' ),
            \'edit_item\'          => __( \'Edit article\', \'lr_article\' ),
            \'view_item\'          => __( \'View article\', \'lr_article\' ),
            \'all_items\'          => __( \'All articles\', \'lr_article\' ),
            \'search_items\'       => __( \'Search articles\', \'lr_article\' ),
            \'parent_item_colon\'  => __( \'Parent articles:\', \'lr_article\' ),
            \'not_found\'          => __( \'No articles found.\', \'lr_article\' ),
            \'not_found_in_trash\' => __( \'No articles found in Trash.\', \'lr_article\' )
        ),
        \'query_var\' => \'Articles\',
        \'rewrite\'   => array(
            \'slug\'          => \'articles\',
            \'with_front\'    => false
        ),
        \'public\'        => true,
        // \'menu_position\' => 5,
        \'menu_icon\'     => plugin_dir_url(__FILE__) . \'av-logo.png\',
        \'supports\'      => array(
            \'title\',
            \'editor\',
            \'thumbnail\',
            \'excerpt\'
        )
    );
    flush_rewrite_rules();

    register_post_type(\'articles\', $args);}

function custom_taxonomy() {

    $taxonomies = array(
        \'hierarchical\' => true,
        \'query_var\' => \'Articles_category\',
        \'rewrite\' => array(
            \'slug\' => \'article-category\',
        ),
        \'labels\' => array(
            \'name\' => \'Articles Category\',
            \'singular_name\' => \'Articles Category\',
            \'edit_item\' => \'Edit Articles Category\',
            \'update_item\' => \'Update Articles Category\',
            \'add_new_item\' => \'Add Articles Category\',
            \'new_item_name\' => \'Add New Articles Category\',
            \'all_items\' => \'All Articles Category\',
            \'search_items\' => \'Search Articles Category\',
            \'popular_items\' => \'Popular Articles Category\',
            \'separate_items_with_comments\' => \'Separate articles Category with Commas\',
            \'add_or_remove_items\' => \'Add or Remove articles Category\',
            \'choose_from_most_used\' => \'Choose from most used articles Category\'));

    register_taxonomy(\'articles_category\', array(\'articles\'), $taxonomies);}
这是我的。htaaccess设置(如果需要)

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /westernlogan/
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /westernlogan/index.php [L]
</IfModule>

# END WordPress

# WP Maximum Execution Time Exceeded
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_input_time 300

</IfModule>

1 个回复
最合适的回答,由SO网友:rudtek 整理而成

为什么不尝试添加:

    \'has_archive\'        => true,
到您的代码?

因此,请替换此行:

    \'public\'        => true,
使用此选项:

    \'public\'        => true,
    \'has_archive\'        => true,
然后通过访问设置/永久链接刷新永久链接。

相关推荐

Testing Plugins for Multisite

我最近发布了一个WordPress插件,它在单个站点上非常有效。我被告知该插件在多站点安装上不能正常工作,我理解其中的一些原因。我已经更新了代码,现在需要一种方法来测试更新后的代码,然后才能转到实时客户的多站点安装。我有一个用于测试的WordPress安装程序的单站点安装,但需要在多站点安装上进行测试。根据我所能找到的唯一方法是在网络上至少有两个站点来安装整个多站点安装,以测试我的插件。设置WordPress的整个多站点安装是插件开发人员的唯一/首选方式,还是有更快的测试环境可用。