Getting Multiple checkbox data wordpress with ajax (only shows one category at a time)










0















I need your expertise about multiple checkbox, Right now even you choose multiple category on the checkbox, it only shows one category, Please check the code below and im using the wordpress system on this project and custom post type, it works but it only shows one category you can check the code below



index start with if terms categories print for the checkbox



<form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
<?php
if( $terms = get_terms( 'categories_printi', 'orderby=name' ) ) : // to make it simple I use default categories
echo '<div id="chkveg" name="categories_printi"';
foreach ( $terms as $term ) :
echo '<label><input type="checkbox" name="categories_printi" value="' . $term->term_id . '">' . $term->name . '</label>'; // ID of the category as the value of an option
endforeach;
echo '</div>';
endif;
?>

<select name="date" id="misha_order_by">
<option name="date" value="DESC">Date &darr;</option><!-- I will explode these values by "-" symbol later -->
<option name="date" value="ASC">Date &uarr;</option>
</select>


<button>Apply filter</button>
<input type="hidden" name="action" value="myfilter">
</form>
<div id="response"></div>


Function.php, Please include content.php so it will show the post item



wp_localize_script( 'misha_scripts', 'misha_loadmore_params', array(
'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php', // WordPress AJAX
'posts' => json_encode( $wp_query->query_vars ), // everything about your loop is here
'current_page' => $wp_query->query_vars['paged'] ? $wp_query->query_vars['paged'] : 1,
'max_page' => $wp_query->max_num_pages
) );
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
function misha_filter_function()


add_action('wp_ajax_myfilter', 'misha_filter_function');
add_action('wp_ajax_nopriv_myfilter', 'misha_filter_function');


Links: For pastie



Function https://www.pastiebin.com/5bebabfbe13bb
index https://www.pastiebin.com/5bebac4218629
Content https://www.pastiebin.com/5bebac5cb163e









share|improve this question


























    0















    I need your expertise about multiple checkbox, Right now even you choose multiple category on the checkbox, it only shows one category, Please check the code below and im using the wordpress system on this project and custom post type, it works but it only shows one category you can check the code below



    index start with if terms categories print for the checkbox



    <form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
    <?php
    if( $terms = get_terms( 'categories_printi', 'orderby=name' ) ) : // to make it simple I use default categories
    echo '<div id="chkveg" name="categories_printi"';
    foreach ( $terms as $term ) :
    echo '<label><input type="checkbox" name="categories_printi" value="' . $term->term_id . '">' . $term->name . '</label>'; // ID of the category as the value of an option
    endforeach;
    echo '</div>';
    endif;
    ?>

    <select name="date" id="misha_order_by">
    <option name="date" value="DESC">Date &darr;</option><!-- I will explode these values by "-" symbol later -->
    <option name="date" value="ASC">Date &uarr;</option>
    </select>


    <button>Apply filter</button>
    <input type="hidden" name="action" value="myfilter">
    </form>
    <div id="response"></div>


    Function.php, Please include content.php so it will show the post item



    wp_localize_script( 'misha_scripts', 'misha_loadmore_params', array(
    'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php', // WordPress AJAX
    'posts' => json_encode( $wp_query->query_vars ), // everything about your loop is here
    'current_page' => $wp_query->query_vars['paged'] ? $wp_query->query_vars['paged'] : 1,
    'max_page' => $wp_query->max_num_pages
    ) );
    add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
    function misha_filter_function()


    add_action('wp_ajax_myfilter', 'misha_filter_function');
    add_action('wp_ajax_nopriv_myfilter', 'misha_filter_function');


    Links: For pastie



    Function https://www.pastiebin.com/5bebabfbe13bb
    index https://www.pastiebin.com/5bebac4218629
    Content https://www.pastiebin.com/5bebac5cb163e









    share|improve this question
























      0












      0








      0








      I need your expertise about multiple checkbox, Right now even you choose multiple category on the checkbox, it only shows one category, Please check the code below and im using the wordpress system on this project and custom post type, it works but it only shows one category you can check the code below



      index start with if terms categories print for the checkbox



      <form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
      <?php
      if( $terms = get_terms( 'categories_printi', 'orderby=name' ) ) : // to make it simple I use default categories
      echo '<div id="chkveg" name="categories_printi"';
      foreach ( $terms as $term ) :
      echo '<label><input type="checkbox" name="categories_printi" value="' . $term->term_id . '">' . $term->name . '</label>'; // ID of the category as the value of an option
      endforeach;
      echo '</div>';
      endif;
      ?>

      <select name="date" id="misha_order_by">
      <option name="date" value="DESC">Date &darr;</option><!-- I will explode these values by "-" symbol later -->
      <option name="date" value="ASC">Date &uarr;</option>
      </select>


      <button>Apply filter</button>
      <input type="hidden" name="action" value="myfilter">
      </form>
      <div id="response"></div>


      Function.php, Please include content.php so it will show the post item



      wp_localize_script( 'misha_scripts', 'misha_loadmore_params', array(
      'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php', // WordPress AJAX
      'posts' => json_encode( $wp_query->query_vars ), // everything about your loop is here
      'current_page' => $wp_query->query_vars['paged'] ? $wp_query->query_vars['paged'] : 1,
      'max_page' => $wp_query->max_num_pages
      ) );
      add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
      function misha_filter_function()


      add_action('wp_ajax_myfilter', 'misha_filter_function');
      add_action('wp_ajax_nopriv_myfilter', 'misha_filter_function');


      Links: For pastie



      Function https://www.pastiebin.com/5bebabfbe13bb
      index https://www.pastiebin.com/5bebac4218629
      Content https://www.pastiebin.com/5bebac5cb163e









      share|improve this question














      I need your expertise about multiple checkbox, Right now even you choose multiple category on the checkbox, it only shows one category, Please check the code below and im using the wordpress system on this project and custom post type, it works but it only shows one category you can check the code below



      index start with if terms categories print for the checkbox



      <form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
      <?php
      if( $terms = get_terms( 'categories_printi', 'orderby=name' ) ) : // to make it simple I use default categories
      echo '<div id="chkveg" name="categories_printi"';
      foreach ( $terms as $term ) :
      echo '<label><input type="checkbox" name="categories_printi" value="' . $term->term_id . '">' . $term->name . '</label>'; // ID of the category as the value of an option
      endforeach;
      echo '</div>';
      endif;
      ?>

      <select name="date" id="misha_order_by">
      <option name="date" value="DESC">Date &darr;</option><!-- I will explode these values by "-" symbol later -->
      <option name="date" value="ASC">Date &uarr;</option>
      </select>


      <button>Apply filter</button>
      <input type="hidden" name="action" value="myfilter">
      </form>
      <div id="response"></div>


      Function.php, Please include content.php so it will show the post item



      wp_localize_script( 'misha_scripts', 'misha_loadmore_params', array(
      'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php', // WordPress AJAX
      'posts' => json_encode( $wp_query->query_vars ), // everything about your loop is here
      'current_page' => $wp_query->query_vars['paged'] ? $wp_query->query_vars['paged'] : 1,
      'max_page' => $wp_query->max_num_pages
      ) );
      add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
      function misha_filter_function()


      add_action('wp_ajax_myfilter', 'misha_filter_function');
      add_action('wp_ajax_nopriv_myfilter', 'misha_filter_function');


      Links: For pastie



      Function https://www.pastiebin.com/5bebabfbe13bb
      index https://www.pastiebin.com/5bebac4218629
      Content https://www.pastiebin.com/5bebac5cb163e






      javascript php wordpress






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 5:07









      techno bisuittechno bisuit

      257




      257






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293519%2fgetting-multiple-checkbox-data-wordpress-with-ajax-only-shows-one-category-at-a%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293519%2fgetting-multiple-checkbox-data-wordpress-with-ajax-only-shows-one-category-at-a%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3

          Museum of Modern and Contemporary Art of Trento and Rovereto