Remove archive page

We want to remove archive page how do we do? Theme X is in use with child theme

Hi There,

I could see that you’re using the custom post type.

To disable the archive page for the custom post type, you have multiple options here.

  • Disable default archive for post type

Disable the archive by setting 'has_archive' => false then keep the page for the post type archive.

  • Redirect archive requests to your page

You can permanently redirect default archive request to your page, by adding this custom code under functions.php file locates in your child theme:

function archive_to_custom_archive() {
    if( is_post_type_archive( 'your_post_type' ) ) {
        wp_redirect( home_url( '/your-page/' ), 301 );
        exit();
    }
}
add_action( 'template_redirect', 'archive_to_custom_archive' );

Hope it helps :slight_smile:

Can you please specify how we disable the archive? Yes post type archive/single we need to keep.

Redirect is not optimal but it’s a hack I prefer to not use. Best would be if we could style archive with x theme/pro but we can not. Other page builders had it for over 1year. I know you working on it but very slow progress and behind all page builders.

So as well please move the header and footer builder from your react framework without any search (not looking for search to assign looking for search to find headers yes we sometimes use a lot of headers for pages) or good workflow to the backend cms. Much easier and better to organise, find and work. Have experience from the top 3 page builders and they are much better than PRO or x Theme. Instead of the clunky and slow react framework for headers and footers etc. Where I can’t use search to find a header.

Hey Mike,

I have replaced the actual post type you’re using with a sample now.

Changing the archive design would currently need overriding the _index.php located in pro\framework\views\global. Here’s the guide to override templates: https://theme.co/apex/forum/t/customizations-best-practices/205

Since you’ll be removing the posts and the pagination which are the only contents of that template, you can delete or best to comment out all the code so you have a reference.

Also, thank you for your feedback regarding the header and footer builders. I will post that as feature request.

Thanks.

Ok so you mean I should just comment it out the code in parent? That will revert as soon as we update the theme. Isn’t it better to sort this with a child version?

Tried even to remove the content in the file without success.

Hi Mike,

Please check the link that was provided, it includes instruction on how you can override that file in your child theme.

Create file _index.php in wp-content\themes\x-child\framework\views\global then add the code below into that file.

<?php

// =============================================================================
// VIEWS/GLOBAL/_INDEX.PHP
// -----------------------------------------------------------------------------
// Includes the index output.
// =============================================================================

$stack = x_get_stack();

if ( is_home() ) :
  $style     = x_get_option( 'x_blog_style' );
  $cols      = x_get_option( 'x_blog_masonry_columns' );
  $condition = is_home() && $style == 'masonry';
elseif ( is_archive() ) :
  $style     = x_get_option( 'x_archive_style' );
  $cols      = x_get_option( 'x_archive_masonry_columns' );
  $condition = is_archive() && $style == 'masonry';
elseif ( is_search() ) :
  $condition = false;
endif;

?>

<?php if ( $condition ) : ?>

  <?php x_get_view( 'global', '_script', 'isotope-index' ); ?>

  <div id="x-iso-container" class="x-iso-container x-iso-container-posts cols-<?php echo $cols; ?>">

    <?php if ( have_posts() ) : ?>
      <?php while ( have_posts() ) : the_post(); ?>
        <?php if ( $stack != 'ethos' ) : ?>
          <?php x_get_view( $stack, 'content', get_post_format() ); ?>
        <?php else : ?>
          <?php x_ethos_entry_cover( 'main-content' ); ?>
        <?php endif; ?>
      <?php endwhile; ?>
    <?php else : ?>
      <?php x_get_view( 'global', '_content-none' ); ?>
    <?php endif; ?>

  </div>

<?php else : ?>

  <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
      <?php x_get_view( $stack, 'content', get_post_format() ); ?>
    <?php endwhile; ?>
  <?php else : ?>
    <?php x_get_view( 'global', '_content-none' ); ?>
  <?php endif; ?>

<?php endif; ?>

<?php pagenavi(); ?>

You can then modify the code and it will override what’s in your parent theme.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.