Custom Post Type - Archive - jQuery is not defined

Hi there,
i want to edit the archive page for my CPT in X Pro Icon.

Therefore i created a custom post type “monatsblatt”.
I copied the _index.php to the childtheme root folder and renamed it to “archive-monatsblatt.php”.

To display the archive I copied and pasted an php-code as described in other forumposts here.

function themeprefix_show_cpt_archives( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) {
$query->set( ‘post_type’, array(
‘post’, ‘nav_menu_item’, ‘monatsblatt’
));
return $query;
}
}
add_filter( ‘pre_get_posts’, ‘themeprefix_show_cpt_archives’ );

but there i get following error:
http://stage.fcg-bielefeld.de/monatsblatt/

When i delete the archive-monatsblatt.php, the standard-archive is being shown.
But i want to edit the archive page, sothat i have the archive-monatsblatt.php.

but i get an error:

Console-Error:
(index):6 Uncaught ReferenceError: jQuery is not defined
at (index):6

In another project with X-Theme, everything worked fine :-/.
In the sourcecode, some isotope script is being loaded?

Hello There,

Thanks for writing in! You are experiencing the issue because the header and footer were not included in your custom template. You will need to have other template files to do it properly. Please follow these steps:
1.) Please create a new file in your computer and insert this code:

<?php

// =============================================================================
// archive-monatsblatt.php
// =============================================================================

?>

<?php x_get_view( x_get_stack(), 'wp', 'monatsblatt' ); ?>

2.) Save this file as archive-monatsblatt.php and upload it in wp-content/themes/x-child/
3.) You will also need to create another file and insert this code:

<?php

// =============================================================================
// VIEWS/ICON/WP-INDEX.PHP
// -----------------------------------------------------------------------------
// Index page output for Icon.
// =============================================================================

?>

<?php get_header(); ?>

  <div class="x-main full" role="main">
    <div class="x-container offset-bottom">

      <?php x_get_view( 'global', '_index-monatsblatt' ); ?>

    </div>
  </div>

  <?php get_sidebar(); ?>
<?php get_footer(); ?>

4.) Save this file as wp-monatsblatt.php and upload this file in wp-content/themes/x-child/framework/views/icon/.
5.) You will create another file again and this time, it should have the contents of _index.php.

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

Please make your modifications first if you have any.

6.) And then saved this file as _index-monatsblatt.php file and upload this in wp-contents/themes/x-child/framwork/views/global/.

When you view the page, http://stage.fcg-bielefeld.de/monatsblatt/, you should no longer be having any error.

Please let us know how it goes.

Thank you, worked fine!

Further, i copied the content-image.php and renamed it to content-monatsblatt.php.

But how can i modify

  • the content of the masonry view (I wan’t to change the content of the masonry view, link the pdf-file in the title)
  • single page of the customposttype.

Hey Kev,

You’re welcome! We are just glad we were able to help you out.
Thanks for letting us know that it has worked for you.

Cheers.

Hi, how can i modify

  • the content of the masonry view (I wan’t to change the content of the masonry view, link the pdf-file in the title)
  • single page of the customposttype.

Thank you :slight_smile:

Hi there,

I recommend using grid plugins such as Essential Grid or The Grid, then you can create grid skins where you can modify how the content and links being displayed.

Modifying the blog masonry layout is a bit complex since it’s composed of multiple parts and being used by all post types and post format (by default). I’m not saying it’s not possible, it’s doable but I recommend getting help from a developer.

The file responsible for title link is \framework\views\ethos\_content-post-header.php and it’s being used by all post types.

Thanks!