10 posts
  • Canada
  • Exclusive Author
  • Has been a member for 2-3 years
kod3r says
Well @ThemeBuddies, remember one thing… when you create custom post types, there is one important note about both rewrite, and has_archive. These arguments are necessary if you want to be able to view an index of your posts without having a specific page template dedicated to it.
'has_archive' => true,
...
'rewrite' => array('slug' => 'businesses', 'with_front' => false)
186 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 1 and 100 dollars
  • United States
ThemeBuddies says

Well @ThemeBuddies, remember one thing… when you create custom post types, there is one important note about both rewrite, and has_archive. These arguments are necessary if you want to be able to view an index of your posts without having a specific page template dedicated to it.
'has_archive' => true,
...
'rewrite' => array('slug' => 'businesses', 'with_front' => false)

This doesn’t make sense to me. I don’t have any CPT in the theme. just posts and pages. Trying to get them all to display on the homepage.

741 posts
  • Has been a member for 5-6 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Most Wanted Bounty Winner
  • Bought between 50 and 99 items
  • Poland
  • Referred between 10 and 49 users
Orbital_Themes says

Well, you get duplicated posts because you run the loop twice… You have pretty much answered your question. You just have to either modify the main query or run a custom one, like this:

$args = array(
    'post_type' => 'page'
);

$page_query = new WP_Query( $args );

if ( $page_query->have_posts() ) : while ( $page_query->have_posts() ) : $page_query->the_post();

$template = get_post_meta( $post->ID, '_wp_page_template', true );

// If the page doesn't have any template assigned - display the default page template
if ( $template == 'default' )
    $template = 'page.php';

get_template_part( $template );

endwhile;
endif;

That’s pretty much it.

186 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 1 and 100 dollars
  • United States
ThemeBuddies says

I like your idea. It seems simple enough but doesn’t return anything. no posts or pages. I understand the code. It does make sense but doesn’t make sense as to why it’s not working. I am going to look into get_template_part and see if I can figure it out.

741 posts
  • Has been a member for 5-6 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Most Wanted Bounty Winner
  • Bought between 50 and 99 items
  • Poland
  • Referred between 10 and 49 users
Orbital_Themes says

Oh, I know what might be wrong. The ‘_wp_page_template’ returns the file name with ’.php’ at the end, e.g. ‘template-portfolio.php’, while the get_template_part function accepts the template name without ’.php’ at the end. You will have to strip that part and you’ll be good to go.

186 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 1 and 100 dollars
  • United States
ThemeBuddies says

I just change it from get_template_part to include and it’s working fine. Now I am editing the code to make it work in my theme. This might be the solution I was looking for. I don’t see any double posts yet so that is good. Thank you for your help.

P.S I have been working on this theme for over two months and have spent countless hours googling looking for any tutorials that I could find on how to make a one page WordPress site. As far as I can tell, there are ZERO tuts out there. Since ThemeForest does look for tutorials to post and sell, this might make a great tut for someone who can share the wisdom.

by
by
by
by
by
by