0

I have created WordPress plugin for my custom post. I have tried all solution for archive, which I have found on Youtube and StackExchange but none of those are working.

I have refreshed permalink for many times tried alternative options.

localhost/westernlogan/articles/ - This archive link giving error (Oops! That page can’t be found.) (even i tried link removing end slash)

localhost/westernlogan/articles/what-is-computer-aided-design-cad/ - this link working fine

archive-articles.php - name of archive page

<?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);}

Here is my .htaaccess setting (in case you need)

# 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>
0
4

why don't you try adding:

    'has_archive'        => true,

to your code?

so replace this line:

    'public'        => true,

with this:

    'public'        => true,
    'has_archive'        => true,

Then refresh your permalinks by visiting settings/permalinks.

1
  • no problem. If it worked can you mark answered? (grey check mark just to left of answer). Thanks! – rudtek Sep 28 '17 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.