10 posts
  • Located in Canada
  • Has been part of the Envato Community for over 2 years
  • Sells items exclusively on Envato Market
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)
189 posts
  • Has been part of the Envato Community for over 2 years
  • Has sold $1+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
  • Has been part of the Envato Community for over 5 years
  • Has sold $40,000+ on Envato Market
+4 more
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.

189 posts
  • Has been part of the Envato Community for over 2 years
  • Has sold $1+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
  • Has been part of the Envato Community for over 5 years
  • Has sold $40,000+ on Envato Market
+4 more
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.

189 posts
  • Has been part of the Envato Community for over 2 years
  • Has sold $1+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by