0

WordPress all post filter by year does not work please help us my code is when i select 2016 for see old post page is reloded bt 2016 post nor show

See this page http://w3ondemand.com/dev/itim/%D7%A2%D7%AA%D7%99%D7%9D-%D7%91%D7%AA%D7%A7%D7%A9%D7%95%D7%A8%D7%AA/test-pagination/

<div class="filter-by">
    <?php
        $selected = '';
        if (isset($_GET['doc_year'])) {
        $selected = '&selected=' . $_GET['doc_year'];
        }

        wp_dropdown_categories('show_option_none=בחר שנה&name=year&taxonomy=years&orderby=name&order=DESC' . $selected);
    ?>
    <script type="text/javascript"><!--
    var dropdown = document.getElementById("year");
    function onCatChange() {
    if (dropdown.options[dropdown.selectedIndex].value > 0) {
    location.href = "<?php the_permalink(); ?>/?doc_year=" + dropdown.options[dropdown.selectedIndex].value;
    } else
    location.href = "<?php the_permalink(); ?>";
    }
    dropdown.onchange = onCatChange;
    --></script>
</div>
4
  • Please explain what " does not work" means here? Thanks
    – birgire
    Commented Apr 18, 2018 at 13:09
  • PLZ CHECK THIS URL w3ondemand.com/dev/itim/… page reloaded but post not showing According to year Commented Apr 18, 2018 at 13:13
  • Please explain your problem better. Do not rely on external sources. Add the error messages that you get to your question text.
    – fuxia
    Commented Apr 18, 2018 at 14:33
  • when i select 2016 for see old post page is reloded bt 2016 post nor show See this page w3ondemand.com/dev/itim/… Commented Apr 19, 2018 at 4:53

1 Answer 1

0
<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
  <option value=""><?php echo esc_attr( __( 'Select Year' ) ); ?></option> 
  <?php wp_get_archives( array( 'type' => 'yearly', 'format' => 'option', 'show_post_count' => 1 ) ); ?>
</select>

This code may help you.

4
  • this is not working Commented Apr 19, 2018 at 5:44
  • remove your all code and try only this code in your div then see what happining Commented Apr 19, 2018 at 5:55
  • Not working plzz check on url Commented Apr 19, 2018 at 6:00
  • i want reload on same page not another Commented Apr 19, 2018 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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