WordPress.org

Forums

Polylang
[resolved] custom Post Archive 404 Error (6 posts)

  1. abodehq
    Member
    Posted 2 years ago #

    Dears,

    Really great Plugin,thanks alooooooot.

    only thing i have one issue is that archiving custom post widget always give me 404 not found i am using risen theme.

    my site :
    http://mos7af.com/isslam/multimedia-archive/who-is-allah/

    go to sermon archive widget and if you click any archive i receive 404 error ...

    pleaaaaaaase save me ....

    http://wordpress.org/extend/plugins/polylang/

  2. abodehq
    Member
    Posted 2 years ago #

    sorry my settings:
    When the front page is visited, set the language according to the browser preference
    The language is set from content. Posts, pages, categories and tags urls are not modified.
    Remove /language/ in pretty permalinks. Example: http://mos7af.com/isslam/en/
    //uncheck settings
    Hide URL language information for default language(uncheck)
    When the front page is visited, set the language according to the browser preference(uncheck)
    //Permalink Settings
    post name http://mos7af.com/isslam/sample-post/

    thanks alot....

  3. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    As far as I know custom post types monthly archives is not natively supported by WordPress. So I guess that you are using a plugin to get that widget. Since both plugins are manipulating urls and not aware of each other, it's likely that it breaks. Could you tell me which plugin it is?

  4. abodehq
    Member
    Posted 2 years ago #

    Thanks for your always prompt response and great help,this widget is from the risen theme itself and i will paste the whole code here hope you can help figure how to help meeeeeeeeeee:(

    /**
     * Multimedia Archives Widget
     *
     * This is based on WordPress wp_get_archives() but modified to allow for post type
     */
    
    if ( ! class_exists( 'Risen_Multimedia_Archives_Widget' ) ) {
    
    	class Risen_Multimedia_Archives_Widget extends WP_Widget {
    
    		// Register widget with WordPress
    		public function __construct() {
    
    			parent::__construct(
    				'risen-multimedia-archives',
    				sprintf( _x( '%s Archives', 'multimedia archive widget', 'risen' ), risen_option( 'multimedia_word_singular' ) ),
    				array(
    					'description' => sprintf( _x( 'Monthly %s archive links.', 'multimedia archive widget', 'risen' ), strtolower( risen_option( 'multimedia_word_singular' ) ) )
    				)
    			);
    
    		}
    
    		// Back-end widget form
    		function form( $instance ) {
    
    			$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0 ) );
    
    			$title = strip_tags( $instance['title'] );
    			$count = $instance['count'] ? 'checked="checked"' : '';
    
    			?>
    
    			<p>
    				<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _ex( 'Title:', 'multimedia archive widget', 'risen'); ?></label>
    				<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
    			</p>
    
    			<p>
    				<input class="checkbox" type="checkbox" <?php echo $count; ?> id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" />
    				<label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _ex( 'Show post counts', 'multimedia archive widget', 'risen' ); ?></label>
    			</p>
    
    			<?php
    
    		}
    
    		// Sanitize widget form values as they are saved
    		function update( $new_instance, $old_instance ) {
    
    			$instance = $old_instance;
    
    			$new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0 ) );
    
    			$instance['title'] = strip_tags( $new_instance['title'] );
    			$instance['count'] = ! empty( $new_instance['count'] ) ? '1' : 0;
    
    			return $instance;
    
    		}
    
    		// Front-end display of widget
    		function widget( $args, $instance ) {
    
    			global $wpdb, $wp_locale;
    
    			// HTML Before
    			echo $args['before_widget'];
    
    			// Title
    			$title = empty( $instance['title'] ) ? sprintf( _x( '%s Archives', 'multimedia archive widget', 'risen' ), risen_option( 'multimedia_word_singular' ) ) : $instance['title'];
    			if ( $title ) {
    				echo $args['before_title'] . $title . $args['after_title'];
    			}				
    
    			// Get archive months for post type
    			$post_type = 'risen_multimedia';
    			$results = (array) $wpdb->get_results( $wpdb->prepare(
    				"
    					SELECT
    						YEAR(post_date) AS <code>year</code>,
    						MONTH(post_date) AS <code>month</code>,
    						count(ID) as posts
    					FROM $wpdb->posts
    					WHERE
    						post_type = %s
    						AND post_status = 'publish'
    					GROUP BY
    						YEAR(post_date),
    						MONTH(post_date)
    					ORDER BY post_date DESC
    				",
    				array(
    					$post_type
    				)
    			) );
    
    			// Output links
    			if ( $results ) {
    
    				// Get post type so have rewrite slug available for URL
    				$pt_obj = get_post_type_object( $post_type );
    				$slug = $pt_obj->rewrite['slug'];
    
    				// Loop months
    				echo '
    <ul>';
    				foreach ( (array) $results as $result ) {
    
    					// Build URL
    					$url = home_url( '/' . $slug . '/' . $result->year . '/' . str_pad( $result->month, 2, '0', STR_PAD_LEFT ) . '/' );
    
    					// Format of link text
    					/* translators: 1: month name, 2: 4-digit year */
    					$text = sprintf( _x('%1$s %2$d', 'multimedia archive widget', 'risen'), $wp_locale->get_month( $result->month ), $result->year );
    
    					// Ahow count after link?
    					$after = '';
    					if ( ! empty( $instance['count'] ) ) { // show count
    						$after = ' (' . $result->posts . ')';
    					}
    
    					// Output link
    					echo get_archives_link( $url, $text, 'html', '', $after );
    
    				}
    				echo '</ul>
    ';
    
    			}
    
    			// HTML After
    			echo $args['after_widget'];
    
    		}
    
    	}
    
    }

    [Please post code or markup between backticks or use the code button. Or better still - use a pastebin. Your posted code may now have been permanently damaged/corrupted by the forum's parser.]

  5. abodehq
    Member
    Posted 2 years ago #

    Chouby,

    I found that if i change the url manually from
    http://mos7af.com/isslam/multimedia-archive/2013/06/
    http://mos7af.com/isslam/en/multimedia-archive/2013/06/

    everything works great, so can you help me to know where i can change this????in the widget code??

    thanks.

  6. abodehq
    Member
    Posted 2 years ago #

    chouby,finally it works for me :)

    i have just changed the home url for the widget posts
    $curlang =pll_current_language();

    in the loop
    $url = home_url( $curlang.'/' . $slug . '/' . $result->year . '/' . str_pad( $result->month, 2, '0', STR_PAD_LEFT ) . '/' );

    now it works great ...

    thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Polylang
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic