Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter andrewrutley

    (@andrewrutley)

    This works for me. Do I need to use wp_reset_postdata(); ? If I remove it I still get the same output. Thanks Rajan V for all your help so far.

    archive-projects.php

    <?php get_header(); ?>
    
    <?php $the_query = new WP_Query('pagename=projects'); ?>
    
    <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    
    		<?php the_content(); ?>
    
    <?php endwhile; else : ?>
    	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; ?>
    
    <?php wp_reset_postdata(); ?>
    
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    		<?php the_content(); ?>
    
    <?php endwhile; else : ?>
    	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; ?>
    
    <?php get_footer(); ?>
    Thread Starter andrewrutley

    (@andrewrutley)

    So I would like

    “/projects”, => for projects page and projects post type
    “/projects/property-management”, => for single post under projects post type

    On “/projects” I would like to display data from both the projects page and the projects post type. At the moment the loop only shows data from the projects post type.

    Thread Starter andrewrutley

    (@andrewrutley)

    I was hoping I wouldn’t have to change the slug as I would like to have urls like the following:

    “/projects”,
    “/projects/property-management”,
    “/projects/job-recruitment”,
    “/projects/cosmetics”

    Once a custom post type is made will it’s slug overwrite a page with the same slug. Meaning the global $posts variable will be an array of the custom post type’s data and not the page data?

Viewing 3 replies - 1 through 3 (of 3 total)