• Bolder Elements

    (@hystericallyme)


    The has_archive option is currently a checkbox, which is fine for most use cases. I’m looking to use a Page I have created in place of the default archive template that WordPress produces. The problem is that the archive has a higher priority than the page even though I have given them the same ‘slug’.

    The code I’ve found online uses the ‘has_archive’ option but passes a string instead. Would it be possible to incorporate this into the plugin?

    'has_archive' => wp_make_link_relative(get_permalink($page_id))
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author wpexplorer

    (@wpexplorer)

    Hey there,

    Sorry, I’m not understanding the issue. If you want to use a standard page page, simply disable the “Has Archive” option. Then you don’t have any conflicts.

    You wouldn’t want to have both a standard page and the automatic archive anyway because that will cause SEO issues with duplicate content.

    • AJ
    Thread Starter Bolder Elements

    (@hystericallyme)

    No worries, it’s a difficult one to explain. And I believe I had it working in the past, but it’s not for me right now. The priorities seem to have shifted. So I created a page with the same slug as my custom post type, but even when I click on the ‘View Page’ in the dashboard, it still brings me to the post archive.

    I do have the ‘has_archive’ option disabled, but the problem is that I am using this plugin to override a custom post type created by a plugin. My guess is it is still enabled from the original plugin? I’m honestly not sure how it all works, I simply looked through some WordPress forums for a solution and found a couple answers mentioning the ‘string’ argument for the ‘has_archive’ option.

    Maybe the solution is something else in this plugin, I don’t know. But if you have any other ideas, please let me know!

    If more context helps, I was originally using ‘WooCommerce’. I could setup a ‘page’ with the slug ‘products’ and it would override the archive. I am switching to Easy Digital Downloads, whose archive seems to trump everything.

    Plugin Author wpexplorer

    (@wpexplorer)

    This plugin will not necessarily “override” a previously registered post type. Because of how WordPress post_type_registration works basically whatever code runs last will take priority and I run my plugin’s code fairly early to ensure that themes and plugins are able to find the registered custom post types and make use of them.

    So what’s happening is your plugin is the one registering the post type and taking priority. In which case no matter how this plugin is coded even if you could enter custom text for the Has Archive field it wouldn’t do anything.

    If you are using the EDD plugin you can easily modify the post type though with a little custom code. For example:

    add_filter( 'edd_download_post_type_args', function( $args ) {
    	$args['has_archive'] = false;
    	return $args;
    } );

    You can view the filter in question on github.

    Hope that helps!

    • AJ
    Plugin Author wpexplorer

    (@wpexplorer)

    I forgot to mention…After you add custom code like this to modify the post type you may need to “flush” your permalinks. You can do this by going to Settings > Permalinks and re-saving them. This is important!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Feature Request: has_archive option’ is closed to new replies.