Guest User

Untitled

a guest
Dec 14th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. <?php
  2. /**
  3. * The template for displaying 404 pages (not found)
  4. *
  5. * @package WordPress
  6. * @subpackage Twenty_Fifteen
  7. * @since Twenty Fifteen 1.0
  8. */
  9.  
  10. get_header(); ?>
  11.  
  12. <div id="primary" class="content-area">
  13. <main id="main" class="site-main" role="main">
  14.  
  15. <?php $post_type_var = get_query_var('post_type'); // Get the custom post type ?>
  16.  
  17. <?php if ( $post_type_var == 'projekt' ) : // Check if we come from the custom post type "projekt" ?>
  18.  
  19. <section class="error-404 not-found">
  20. <header class="page-header">
  21. <h1 class="page-title"><?php esc_html_e( 'Oops! That project can&rsquo;t be found.', 'twentyfifteen-child' ); ?></h1>
  22. </header><!-- .page-header -->
  23.  
  24. <div class="page-content">
  25. <p><?php esc_html_e( 'It looks like the project you were looking for could not be found at this location. Maybe try a search?', 'twentyfifteen-child' ); ?></p>
  26.  
  27. <?php get_search_form(); ?>
  28.  
  29. <h2><?php esc_html_e( 'Latest Projects', 'twentyfifteen-child' ); ?></h2>
  30.  
  31. <?php
  32. //args
  33. $args = array(
  34. 'post_type' => 'projekt',
  35. 'posts_per_page' => 3
  36. );
  37.  
  38. // the query
  39. $project_query = new WP_Query( $args ); ?>
  40.  
  41. <?php if ( $project_query->have_posts() ) : ?>
  42.  
  43. <ul class="latest-projects">
  44. <?php while ( $project_query->have_posts() ) : $project_query->the_post(); ?>
  45. <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
  46. <?php endwhile; ?>
  47. </ul>
  48.  
  49. <?php wp_reset_postdata(); ?>
  50.  
  51. <?php else: ?>
  52. <p><?php esc_html_e( 'Sorry, no posts matched your criteria.', 'twentyfifteen-child' ); ?></p>
  53. <?php endif; ?>
  54. </div><!-- .page-content -->
  55. </section><!-- .error-404 -->
  56.  
  57. <?php else : // All other post types like post and page get the normal 404 content ?>
  58.  
  59. <section class="error-404 not-found">
  60. <header class="page-header">
  61. <h1 class="page-title"><?php esc_html_e( 'Oops! That page can&rsquo;t be found.', 'twentyfifteen-child' ); ?></h1>
  62. </header><!-- .page-header -->
  63.  
  64. <div class="page-content">
  65. <p><?php esc_html_e( 'It looks like nothing was found at this location. Maybe try a search?', 'twentyfifteen-child' ); ?></p>
  66.  
  67. <?php get_search_form(); ?>
  68. </div><!-- .page-content -->
  69. </section><!-- .error-404 -->
  70.  
  71. <?php endif; ?>
  72.  
  73. </main><!-- .site-main -->
  74. </div><!-- .content-area -->
  75.  
  76. <?php get_footer(); ?>
Add Comment
Please, Sign In to add comment