WordPress.org

Ready to get started?Download WordPress

Forums

HELP! Custom Post Type Pagination 404 Problem (3 posts)

  1. onur89tr
    Member
    Posted 1 year ago #

    Hi. First, sorry for my bad English. I did a WordPress theme. And I added to my theme Photo Gallery with custom post type. But I have a problem. My custom post type is giving 404 error in pagination (if paged is greater than 2). My theme link: http://www.onurunwebsitesi.com/

    Maybe I can't understanding your English. Please do changes in theme and send my e-mail. If you write what you do, I will be more happy. Thanks.

  2. onur89tr
    Member
    Posted 1 year ago #

    Moderators edited my first message. And I copy-paste my codes.

    functions.php

    add_action( 'init', 'register_cpt_fotograf' );
    function register_cpt_fotograf() {
    $labels = array(
    'name' => _x( 'Fotoğraflar', 'fotografs' ),
    'singular_name' => _x( 'Fotoğraf', 'fotograf' ),
    'add_new' => _x( 'Yeni Ekle', 'fotograf' ),
    'add_new_item' => _x( 'Yeni Fotoğraf Ekle', 'fotograf' ),
    'edit_item' => _x( 'Fotoğrafı Düzenle', 'fotograf' ),
    'new_item' => _x( 'Yeni Fotoğraf', 'fotograf' ),
    'view_item' => _x( 'Fotoğrafı Önizle', 'fotograf' ),
    'search_items' => _x( 'Fotoğraf Ara', 'fotograf' ),
    'not_found' => _x( 'Fotoğraf Bulunamadı', 'fotograf' ),
    'not_found_in_trash' => _x( 'Çöpte Fotoğraf Bulunamadı', 'fotograf' ),
    'parent_item_colon' => _x( 'Ana Fotoğraf:', 'fotograf' ),
    'menu_name' => _x( 'Fotoğraflar', 'fotograf' ),
    );
    $args = array(
    'labels' => $labels,
    'hierarchical' => false,
    'supports' => array( 'title', 'author', 'thumbnail', 'custom-fields', 'comments' ),
    'public' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'show_in_nav_menus' => false,
    'publicly_queryable' => true,
    'exclude_from_search' => false,
    'has_archive' => true,
    'query_var' => true,
    'can_export' => true,
    'rewrite' => array('slug' => 'fotograflar'),
    'capability_type' => 'post'
    );
    register_post_type( 'fotograf', $args );
    } 
    
    function mySearchFilter_0987($query) {
        $post_type = $_GET['post_type'];
        if (!$post_type) {
            $post_type = 'any';
        }
        if ($query->is_search) {
            $query->set('post_type', $post_type);
        };
        return $query;
    }; 
    
    add_filter('pre_get_posts','mySearchFilter_0987');

    archive-fotograf.php

    <?php get_header(); ?>
    <?php $aranan= $_GET['s']; ?>
    <div id="content">
    <?php 
    
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array( 'post_type' => 'fotograf' , 's' => $aranan, 'posts_per_page' => 3, 'paged' => $paged );
    query_posts($args);
    
    if (have_posts()) : $rakam=0; ?><div id="FGaleri"><div id="FGaleri_Ic"><div id="FGaleriBaslik">Fotoğraf Galerisi 
    
    <form action="<?php echo get_bloginfo('wpurl'); ?>" id="searchform" method="get" name="searchform">
    <input name="s" id="s" type="text" value=""/>
    <input type="hidden" name="post_type" value="fotograf" />
    <input id="searchsubmit" type="submit" value="Ara"/>
    </form>
    
    </div><div class="FGaleri_Ic_2"><?php while( have_posts() ) : the_post(); $rakam++; ?>
    <div class="FGaleriItem2" style="<?php if ($rakam % 5 == 0 ) { ?>margin-right: 0px;<?php } ?>"><div class="ResimUst"><?php if (has_post_thumbnail()) { ?><a href="<?php the_permalink() ?>"><?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );$url2 = get_bloginfo('template_directory') . "/timthumb.php?src=" . $url . "&w=100&h=100&zc=1"; ?><img src="<?php if(get_option('of_timthumb')=="true") { echo $url2; } else { echo $url; } ?>" alt="" title="" width="100" height="100" /></a><?php } ?></div><div class="ResimAlt"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></div></div><?php if (($rakam % 5 == 0) && ($rakam > 4)) { ?><div class="clearboth2"></div><?php } ?><?php endwhile; ?></div></div></div><div class="clearboth"></div>
    <div id="navigasyon"><?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?><span class="previous-entries"><?php next_posts_link('« Daha Eski Fotoğraflar') ?></span><span class="next-entries"><?php previous_posts_link('Daha Yeni Fotoğraflar»') ?></span><?php } ?></div>
    <?php else : ?><p class="bulunamadi">Yazı bulunamadı.</p><?php endif; ?>
    </div><?php wp_reset_query(); ?><?php get_sidebar(); ?></div><?php get_footer(); ?>

    single-fotograf.php

    <?php get_header(); ?>
    <div id="content">
    <?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    			<?php setPostViews(get_the_ID());?>
    		<div class="post"><div class="Post_Ic">
    <div class="posttitle"><?php echo the_title(); ?></div>
    <div class="clearboth"></div>
    <div class="postdiger">
    <div class="yazar"><?php the_author_posts_link(); ?></div>
    <div class="aralik"></div>
    <div class="tarih"><?php the_time('d F Y'); ?></div>
    <div class="aralik"></div>
    <div class="saat"><?php the_time('H:i'); ?></div>
    <div class="aralik"></div>
    <div class="okunma"><?php echo getPostViews(get_the_ID());?></div>
    <div class="aralik"></div>
    <div class="yorum"><?php comments_popup_link('Yorum Yok', '1 Yorum', '% Yorum'); ?></div>
    <?php if(current_user_can('manage_options'))
     { ?><div class="aralik"></div><div class="duzenle"><?php edit_post_link(__('Düzenle', ''), '', ''); ?></div><?php } ?>
    </div>
    <div class="entry">
    <div class="navigasyonfoto">
    <span class="previous-entries"><?php previous_post_link('%link') ?></span><span class="next-entries"><?php next_post_link('%link') ?></span>
    </div>
    <div class="clearboth3"></div>
    <?php the_post_thumbnail('fotograflar', array('alt' => '', 'class' => 'foto aligncenter')); ?>
    <div class="FotoYazi"><?php the_title(); ?></div>
    <div class="clearboth3"></div>
    <div class="navigasyonfoto">
    <span class="previous-entries"><?php previous_post_link('%link') ?></span><span class="next-entries"><?php next_post_link('%link') ?></span>
    </div>
    </div>
    <div class="clearboth"></div>
    <div class="etiketler"><?php the_tags('','',''); ?></div>
    <?php wp_link_pages(array('before' => '<p><strong>Sayfalar:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    <?php if (trim(get_option('of_ads46860_2'))!="") { ?> <div id="reklamlar_4"><?php echo get_option('of_ads46860_2');?> </div><div class="clearboth3"></div><?php }
    
    if (get_option('of_paylasbuton') == 'true') { ?>
    
    <div class="Paylas"><a class="fb" target="_blank" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" title="Facebook'ta paylaşmak için tıklayın!">&nbsp;</a><a class="tw" target="_blank" href="http://twitter.com/share?text=<?php the_title(); ?>&url=<?php the_permalink(); ?>" title="Twitter'da paylaşmak için tıklayın!">&nbsp;</a><a class="gp" title="Google+'ta paylaşmak için tıklayın!" href="https://plusone.google.com/_/+1/confirm?hl=tr&url=<?php the_permalink(); ?>">&nbsp;</a></div><div class="clearboth3"></div>
    <?php } ?>
    
    <?php if (get_option('of_ybilgi')=="true") { ?><div id="authorbox">
                    <div id="sol"><?php echo get_avatar( get_the_author_email(), '53' ); ?></div><div id="sag"><div id="hakkinda"><?php the_author(); ?> hakkında: </div><div id="hakkindaicerik"><?php the_author_meta( 'description' ); ?></div></div>
    </div><div class="clearboth3"></div>
    <?php } ?>
    <div class="clearboth"><?php comments_template(); ?></div></div><?php endwhile; ?>
    <div class="clearboth"></div>
    <?php else : ?>
    <p class="bulunamadi">Yazı bulunamadı.</p>
    <?php endif; ?>
    </div>
    <?php get_sidebar(); ?>
    </div><?php get_footer(); ?>

    Where is the problem? Please help me. :(

  3. onur89tr
    Member
    Posted 1 year ago #

    Any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic