Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

my site looks like:

Page-1 (page.php)
... Subpage-1 (custom-collection.php; Custom Post Type)
...... Filtering Output-Post (custom-collection-single.php)

When I open the filtering output-post by using /%postname% for permalinks I get 404 error page.

Some code:

custom-collection.php

<?php $args = array( 'post_type' => 'weine', 'posts_per_page' => -1, 'orderby' => 'rand' );

// ============================= WHITEWINE ===============================
if( is_page('147') ) { 

$args = array(
    'tax_query' => array(
        array(
            'taxonomy' => 'sorte',
            'field' => 'slug',
            'terms' => array('weisswein')
        )
    )
);
}

// ============================= REDWINE ===============================

...

// =========================== All WINES ==================================
else {}


$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>

    <a class="item" rel="wine" href="<?php the_permalink(); ?>" >
    <?php the_post_thumbnail('wine-flow', array('class' => 'content')); ?>
    <!-- <div class="label">Slider Label</div> -->
    </a>

<?php endwhile; ?>

custom-collection-single.php

<?php get_template_part( 'loop', 'single-empty' ); ?>

<?php
    echo '<div class="wein-bottle-thumb">';
    the_post_thumbnail('wine-flow'); 

            echo '...';

?>

The Loop (loop-single-empty.php)

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

<?php endwhile; ?>

I try to added this to my functions.php

add_action('admin_init', 'flush_rewrite_rules');

When I use standard permalinks everything works fine for me.
.htaccess: <IfModule mod_rewrite.c> ... is active

Thanks for your help.
Ogni

share|improve this question

1 Answer 1

Your setup is all over the place. Lets refer to the visual overview here:

http://codex.wordpress.org/Template_Hierarchy#Visual_Overview

enter image description here

Your page is going to use the page.php template.

Your custom post type weine will use single-weine.php

Your custom taxonomy sorte ( probably not the best name as it might clash ) will use the template taxonomy-sorte.php

So we can expect by default to have a weine post with the title "example" to live at:

example.com/weine/example

and the sorte taxonomy term 'examplesorte' will have its archive at:

example.com/sorte/examplesorte

What I expect you're trying to do is change it so that there is no /weine/, or you think that by using postname that it will change the link of 'weine' posts. This is incorrect, and while there is code out there that may change this, I strongly recommend against this as it introduces dangerous permalink clashes. It's also better if you use the weine URL structure to your advantage.

e.g. I would recommend modifying the rewrite base of the sorte taxonomy to use weine/sorte as it's base, giving you URLs such as:

example.com/weine/sorte/examplesorte

A Note On Flushing Rewrites

You need to flush them when your custom post types and taxonomies change, but never do it on admin_init or init. Regenerating rewrite rules is slow and expensive, and by putting it on those hooks, you're massively slowing down your site, and introducing potential bugs and problems.

I would also kill trying to set custom post types parents as that of a normal page. Use the slug in the rewrite base but go no further than that.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.