Add Category to display on a theme Page

Hi,

I'm hoping someone can help me. We all know category pages can look a bit plain. I'm looking to add category listings to a theme page. This way, I can have a more visually pleasing page that truly matches the rest of the pages.

I found a plugin in Wordpress.org Plugin Directory (Add Category to Pages). It's exactly what I've been looking for, but it haven't been updated in two years and it's creating a conflict. Does anybody have a solution?

Thanks in advance for your help.

BrooklynScoop

  • BrooklynScoop

    Hi Nastia,

    Thanks for your reply. I had checked that plugin out. It places an excerpt of the Post on the default WordPress Category page. I'm looking for a plugin that would allow the excerpts of the Post appear on a specified Page. This way I will have more creative control where as the Category page is pretty limited.

    The Add Category to Pages plugin is exactly what i"m looking for. To accomplish this, it uses shortcodes. The reason I can't use that plugin is because it hasn't been updated in two years and It's conflicting with Visual Composer, which my theme uses.

    Thanks
    - BrooklynScoop

  • Panos

    Hello BrooklynScoop ,

    It probably hasn't been updated because it contains only basic functions which have not been deprecated, has no security risk and doesn't need to add any new features. I am not saying that you should be using it, especially since you mention that it conflicts with Visual Composer.

    I searched the web but couldn't find anything similar in a plugin, but I did find several tutorials on how to add custom code in your functions.php (in your child theme) to achieve it.

    First try using the code the plugin you mention uses:

    function add_taxonomies_to_pages() {
          register_taxonomy_for_object_type( 'post_tag', 'page' );
          register_taxonomy_for_object_type( 'category', 'page' );
      } 
    
     add_action( 'init', 'add_taxonomies_to_pages' );
    
     if ( ! is_admin() ) {
     add_action( 'pre_get_posts', 'category_and_tag_archives' );
    
       }
    
    // Add Page as a post_type in the archive.php and tag.php 
    
    function category_and_tag_archives( $wp_query ) {
    
    	$my_post_array = array('post','page');
    
    	if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) )
          $wp_query->set( 'post_type', $my_post_array );
    
        if ( $wp_query->get( 'tag' ) )
          $wp_query->set( 'post_type', $my_post_array );
    
      }

    Paste the above snippet in the functions.php file of your child theme and let us know if it causes any issues with visual composer, and if it does please describe what does not work on VC. Perhaps you could grant access to have a closer look.

    Looking forward to your reply!

    Kind regards,
    Panos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.