Advertisement
trymedo

Custom Category "Landing Pages" Requires Page Builder plugin

May 16th, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php // Custom template for category landing pages - name this page category-loop.php
  2.  
  3. // Keep in mind that you may need to either a) install the remove Category Base plugin (to remove /category/ from archive pages) or b) add a parent page to these 'landing pages' that has a slug of 'category'.
  4.  
  5. // Get the current path.
  6. $page = get_page_by_path( $_SERVER['REQUEST_URI'] );
  7. if($page && $page->post_status == 'publish') {
  8.     // If there is a published page that shares this path, use that as the landing page.
  9.     // Attempt to render the siteorigin page content, or fallback to standard post_content.
  10.     if( function_exists('siteorigin_panels_render') && $content = siteorigin_panels_render( $page->ID ) ) {
  11.         echo $content;
  12.     } else {
  13.         echo apply_filters('the_content', $page->post_content );
  14.     }
  15.  
  16. } else {
  17.     // Otherwise, use the default loop template to list all the posts within this category.
  18.     get_template_part('templates/loop', get_post_format());
  19. }
  20.  
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement