Quantcast
Channel: Nederland » Recent Posts
Viewing all articles
Browse latest Browse all 30043

manas81 on "custom categories naar 404 pagina"

$
0
0

Beste coders!

Al weken bezig om het onderstaande werkend te krijgen:

1. PROBLEMEN:
- custom categories links redirect nu naar 404 pagina (query hulpvraag)
- custom posts van custom categories tonen werkend krijgen (query hulpvraag)

2. VOORBEELD:
Custom categorie 1 (site.nl/citaten-van/naam-persoon/) => 404 pagina
- custom post 1 (site.nl/citaten/uitspraak-van-over/) => werkt goed
- custom post 2 (site.nl/citaten/uitspraak-van-over-iets-anders/) => werkt goed

Custom Categorie 2
- custom post 1
etc.

3 CODE:

permalink instelling: /%category%/%postname%/

FUNCTIONS.PHP

add_action('init', 'create_citaten');
function create_citaten() {
$citaten_args = array(
'labels' => array(
'name' => __( 'Citaten' ),
'singular_name' => __( 'Citaat' ),
'add_new' => __('Voeg citaat toe'),
'all_items' => __('Alle citaten'),
'edit_item' => __('Bewerk citaat'),
'add_new_item' => __('Voeg citaat toe'),
),
'public' => true,
'rewrite' => array( 'slug' => 'citaten', 'with_front' => false ),
'taxonomies' => array('citaten-van'),
//'taxonomies' => array('category'),
'hierarchical' => false,
'has_archive' => true,
'supports' => array('title','thumbnail','editor')
);
register_post_type('citaten', $citaten_args);
flush_rewrite_rules();
}

// Add custom taxonomies for Citaten post type
add_action('init','register_citaten_van_taxonomy');
function register_citaten_van_taxonomy() {

// create the array for 'labels'
$labels = array(
'name' => ( 'Alle citaten van' ),
'singular_name' => ( 'Citaat van' ),
'search_items' => ( 'Zoek citaten van' ),
'all_items' => ( 'Alle citaten van' ),
'parent_item' => ( 'Hoofd citaten van' ),
'parent_item_colon' => ( 'Hoofd citaten van:' ),
'edit_item' => ( 'Bewerkt citaten van' ),
'update_item' => ( 'Update citaten van' ),
'add_new_item' => ( 'Nieuwe citaten van' ),
'new_item_name' => ( 'Nieuwe naam citaten van' ),
);

register_taxonomy('citaten-van',array('citaten'),array(
'hierarchical' => true,
'labels' => $labels, // adds the above $labels array
'public'=> true,
'show_ui'=> true,
'query_var'=> true,
'rewrite' => array( 'slug' => 'citaten-van' ), // changes name in permalink structure
));
}

ARCHIVE-CITATEN.PHP

<?php
global $query_string;
parse_str( $query_string, $my_query_array );
$paged = ( isset( $my_query_array['paged'] ) && !empty( $my_query_array['paged'] ) ) ? $my_query_array['paged'] : 1;
query_posts('taxonomy=citaten-van&post_type=citaten&paged='.$paged);

// The Loop
while (have_posts()) : the_post(); ?>


Viewing all articles
Browse latest Browse all 30043

Trending Articles