• Resolved misharnet

    (@misharnet)


    I am trying to adjust WordPress core Archives Widget so it appears as a nice looking drop down menu. I did it and it works, but when wp_debug is set to true it shows the following Notice: Undefined offset: 1 in C:\xampp…

    it is in this code:

    <?php
    		/**
    		 * Filter the arguments for the Archives widget.
    		 *
    		 * @since 2.8.0
    		 *
    		 * @see wp_get_archives()
    		 *
    		 * @param array $args An array of Archives option arguments.
    		 */
    		$archives = strip_tags(wp_get_archives( apply_filters( 'nsgen_archive_widgets_args', array(
    			'type'            => 'monthly',
    			'format'          => 'custom',
    			'echo'            => 0,
    			'after'           => ','
    		) ) ) );
    		$archives = explode(',', $archives);
    		$months = array();
    		$years = array();
    		// Grab our years first
    		foreach ($archives as $archive) {
    			$archive = explode(' ', $archive);
    			if (isset($archive[1])) {
    				array_push($years, $archive[1]);
    			}
    		}
    		$years = array_values(array_unique($years));
    		$i = 0;
    		foreach ($years as $year) {
    		?><li class="nsgen-archive-year"><a><?php
    			echo $year;
    			?></a><ul><?php
    			foreach ($archives as $archive) {
    				$archive = explode(' ', $archive);
                                       if ($archive[1] == $year) {
    					echo '<li class="nsgen-archive-month"><a href="' .
    					// Get the archive link
    					get_month_link($year, date("m", strtotime($archive[0] . '-' . $year))) .
    					'">' . trim($archive[0]) . '</a></li>';
          			}
    			}
    			?></ul><?php
    		?></li><?php
    		}
    ?>

    this part: if ($archive[1] == $year) {
    Can some one help, please.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Undefined offset’ is closed to new replies.