Forum Replies Created

Viewing 15 replies - 16 through 30 (of 63 total)
  • Thread Starter edow

    (@edow)

    Hi, no problem at all. I hope you had a great time.

    When Belgie and Namen are currently selected and I change Land to Nederland then the regio button is not selected at all. The URL is indeed /?land=nederland&regio=namen which is wrong for what I want, but I think logical for PHP.

    If I’m on page 2 and I submit the form it redirects to page one, so I’m not sure if it’s working on other pages, but I don’t think it’s a PHP problem, but I think I want something which is not possible with PHP 🙂

    As you say I think with javascript should be checked if there’s a change in the radio button Land and then reset the Regio button. I asked for a javascript solution on Stackoverflow, but with no results. Maybe I have to ask it once more.

    Again thank you for your insight, I’ll see if I can make it happen with javascript.

    Thread Starter edow

    (@edow)

    I’m extending the form and came with the following idea to show only the “regio” which belongs to the right “land”:

    <form name="sidebarform" onChange="document.forms.sidebarform.submit();">
    		<input type="hidden" name="paged" value="1">
    
    		<?php
    		if (is_category()){
    		  $cat = get_query_var('cat');
    		  $yourcat = get_category ($cat);
    		}
    		$tag_IDs = array();
    		query_posts('category_name='.$yourcat->slug);
    		if (have_posts()) : while (have_posts()) : the_post();
    		  $posttags = get_the_tags();
    		  if ($posttags):
    			foreach($posttags as $tag) {
    			if (!in_array($tag->term_id , $tag_IDs)):
    			   $tag_IDs[] = $tag->term_id;
    			   $tag_names[$tag->term_id] = $tag->name;
    			   $tag_slug[$tag->term_id] = $tag->slug;
    			 endif;
    			}
    		  endif;
    		endwhile; endif;
    		wp_reset_query();
    
    		$getTag = $_GET["tag"];
    		if ($getTag == '') {
    			$tag_showall = 'checked';
    			}
    		if (!empty($tag_IDs)){
    			echo '<h3>Het meest geschikt voor</h3>';
    			echo '<input type="radio" name="tag" value="" '.$tag_showall.'> Alles weergeven<br>';
    		}
    		foreach($tag_IDs as $tag_ID){
    			$checked = $tag_slug[$tag_ID];
    			echo '<input type="radio" name="tag" value="'.$checked.'"' ;
    			if((isset($_GET["tag"])) && $_GET["tag"] == $checked) {
    			echo ' checked="checked"';
    			}
    			echo '> '.$tag_names[$tag_ID].'<br>';
    		}
    		?>
    
    		<div class="margin25px"></div>
    
    		<?php
    			$land = $_GET["land"];
    			$regio = $_GET["regio"];
    
    			if ($land == 'all' OR $land == '') {
    			$land_showall = 'checked';
    			}
    			elseif ( $land == 'nederland' ) {
    			$landNL = 'checked';
    			}
    			elseif ( $land == 'belgie' ) {
    			$landBE = 'checked';
    			}
    			if ($regio == 'all' OR $regio == '') {
    			$regio_showall = 'checked';
    			}
    			elseif ( $regio == 'groningen' ) {
    			$regioNL1 = 'checked';
    			}
    			elseif ( $regio == 'friesland' ) {
    			$regioNL2 = 'checked';
    			}
    			elseif ( $regio == 'drenthe' ) {
    			$regioNL3 = 'checked';
    			}
    			elseif ( $regio == 'overijssel' ) {
    			$regioNL4 = 'checked';
    			}
    			elseif ( $regio == 'flevoland' ) {
    			$regioNL5 = 'checked';
    			}
    			elseif ( $regio == 'gelderland' ) {
    			$regioNL6 = 'checked';
    			}
    			elseif ( $regio == 'utrecht' ) {
    			$regioNL7 = 'checked';
    			}
    			elseif ( $regio == 'noord-holland' ) {
    			$regioNL8 = 'checked';
    			}
    			elseif ( $regio == 'zuid-holland' ) {
    			$regioNL9 = 'checked';
    			}
    			elseif ( $regio == 'zeeland' ) {
    			$regioNL10 = 'checked';
    			}
    			elseif ( $regio == 'noord-brabant' ) {
    			$regioNL11 = 'checked';
    			}
    			elseif ( $regio == 'limburg' ) {
    			$regioNL12 = 'checked';
    			}
    			elseif ( $regio == 'namen' ) {
    			$regioBE1 = 'checked';
    			}
    			elseif ( $regio == 'waals-brabant' ) {
    			$regioBE2 = 'checked';
    			}
    			elseif ( $regio == 'west-vlaanderen' ) {
    			$regioBE3 = 'checked';
    			}
    		?>
    
    		<h3>Land</h3>
    			<input type="radio" name="land" value="all" <?php echo $land_showall; ?>> Alles weergeven<br>
    			<input type="radio" name="land" value="nederland" <?php echo $landNL; ?>> Nederland<br>
    			<input type="radio" name="land" value="belgie" <?php echo $landBE; ?>> België
    
    			<?php
    		if ( $land == 'all' OR $land == '' ) {
    		echo '<div class="margin25px"></div>';
    		echo '<h3>Regio</h3>';
    		echo '<input type="radio" name="regio" value="all" '.$land_showall.'> Alles weergeven<br>';
    		echo '<input type="radio" name="regio" value="groningen" '.$regioNL1.'> Groningen<br>';
    		echo '<input type="radio" name="regio" value="friesland" '.$regioNL2.'> Friesland<br>';
    		echo '<input type="radio" name="regio" value="drenthe" '.$regioNL3.'> Drenthe<br>';
    		echo '<input type="radio" name="regio" value="overijssel" '.$regioNL4.'> Overijssel<br>';
    		echo '<input type="radio" name="regio" value="flevoland" '.$regioNL5.'> Flevoland<br>';
    		echo '<input type="radio" name="regio" value="gelderland" '.$regioNL6.'> Gelderland<br>';
    		echo '<input type="radio" name="regio" value="utrecht" '.$regioNL7.'> Utrecht<br>';
    		echo '<input type="radio" name="regio" value="noord-holland" '.$regioNL8.'> Noord-Holland<br>';
    		echo '<input type="radio" name="regio" value="zuid-holland" '.$regioNL9.'> Zuid-Holland<br>';
    		echo '<input type="radio" name="regio" value="zeeland" '.$regioNL10.'> Zeeland<br>';
    		echo '<input type="radio" name="regio" value="noord-brabant" '.$regioNL11.'> Noord-Brabant<br>';
    		echo '<input type="radio" name="regio" value="limburg" '.$regioNL12.'> Limburg<br><br>';
    		echo '<input type="radio" name="regio" value="namen" '.$regioBE1.'> Namen<br>';
    		echo '<input type="radio" name="regio" value="waals-brabant" '.$regioBE2.'> Waals-Brabant<br>';
    		echo '<input type="radio" name="regio" value="west-vlaanderen" '.$regioBE3.'> West-Vlaanderen<br>';
    		}
    
    		elseif ( $land == 'nederland' ) {
    		echo '<div class="margin25px"></div>';
    		echo '<h3>Regio</h3>';
    		echo '<input type="radio" name="regio" value="all" '.$regio_showall.'> Alles weergeven<br>';
    		echo '<input type="radio" name="regio" value="groningen" '.$regioNL1.'> Groningen<br>';
    		echo '<input type="radio" name="regio" value="friesland" '.$regioNL2.'> Friesland<br>';
    		echo '<input type="radio" name="regio" value="drenthe" '.$regioNL3.'> Drenthe<br>';
    		echo '<input type="radio" name="regio" value="overijssel" '.$regioNL4.'> Overijssel<br>';
    		echo '<input type="radio" name="regio" value="flevoland" '.$regioNL5.'> Flevoland<br>';
    		echo '<input type="radio" name="regio" value="gelderland" '.$regioNL6.'> Gelderland<br>';
    		echo '<input type="radio" name="regio" value="utrecht" '.$regioNL7.'> Utrecht<br>';
    		echo '<input type="radio" name="regio" value="noord-holland" '.$regioNL8.'> Noord-Holland<br>';
    		echo '<input type="radio" name="regio" value="zuid-holland" '.$regioNL9.'> Zuid-Holland<br>';
    		echo '<input type="radio" name="regio" value="zeeland" '.$regioNL10.'> Zeeland<br>';
    		echo '<input type="radio" name="regio" value="noord-brabant" '.$regioNL11.'> Noord-Brabant<br>';
    		echo '<input type="radio" name="regio" value="limburg" '.$regioNL12.'> Limburg';
    		}
    
    		elseif ( $land == 'belgie' ) {
    		echo '<div class="margin25px"></div>';
    		echo '<h3>Regio</h3>';
    		echo '<input type="radio" name="regio" value="all" '.$regio_showall.'> Alles weergeven<br>';
    		echo '<input type="radio" name="regio" value="namen" '.$regioBE1.'> Namen<br>';
    		echo '<input type="radio" name="regio" value="waals-brabant" '.$regioBE2.'> Waals-Brabant<br>';
    		echo '<input type="radio" name="regio" value="west-vlaanderen" '.$regioBE3.'> West-Vlaanderen<br>';
    		}
    		?>
    		</form>

    It’s working, but there’s one problem. If I click on “belgie” it shows the “regio” which are in “belgie”. For example I click on “namen” the URL will be like /?land=belgie&regio=namen. That’s alright.
    But when after that I click on “nederland” (so another “land”) the URL become /?land=nederland&regio=namen. Which is wrong, because “namen” is not in “nederland”.

    Because of this the posts aren’t filtering the right way. What I want is when I change the “land” the “regio” will be “all”.
    So, every time “land” is clicked the URL should be /?land=belgie&regio=all (if clicked on the land “belgie”) OR /?land=nederland&regio=all (if clicked on the land “nederland) OR /?land=all&regio=all (if clicked on the land “all”).

    I hope I’m clear in what I want. I tried a lot of things, even with hidden fields, but only the radio buttons change and not the URL.

    Is it possible and if so, what do I do wrong?

    Thread Starter edow

    (@edow)

    Thanks for your reply. I’ll test it some more soon. Thanks again for all your great help!! You solved the biggest problems on my website. I’m very happy and again I learned a lot.

    Thread Starter edow

    (@edow)

    Thanks for your reply. Instead of an empty string I changed the value to ?land=all.

    I used your suggested code in functions.php, but a little different:

    function wpa_filter_home_query( $query ){
    	if( $query->is_main_query()
        && isset( $_GET['land'] )
    	&& isset( $_GET['provincie'] )
    	&& $_GET['land'] != "all"
    	&& $_GET['provincie'] != "all" ) {
    		$meta_query = array(
    		'relation' => 'AND',
    			array(
                    'key' => 'land',
                    'value' => array( $_GET['land'] )
                ),
    			array(
                    'key' => 'provincie',
                    'value' => array( $_GET['provincie'] )
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    	elseif( $query->is_main_query()
    	&& isset( $_GET['land'] )
    	&& $_GET['land'] != "all" ) {
            $meta_query = array(
    			array(
                    'key' => 'land',
                    'value' => array( $_GET['land'] )
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    	elseif( $query->is_main_query()
    	&& isset( $_GET['provincie'] )
    	&& $_GET['provincie'] != "all" ) {
            $meta_query = array(
    			array(
                    'key' => 'provincie',
                    'value' => array( $_GET['provincie'] )
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    }
    add_action( 'pre_get_posts', 'wpa_filter_home_query' );

    Is && $_GET['land'] != "all" used alright? Or should I use another IF statement? It seems to work right now, but I want a clean code.

    In my sidebar I used the following code:

    $land = $_GET["land"];
    $provincie = $_GET["provincie"];
    if ($land == 'all') {
    $showall_land = 'checked';
    }
    
    <h3>Land</h3>
    <input type="radio" name="land" value="all" <?php echo $showall_land; ?>> Alles weergeven<br>}

    And if clicked “Alles weergeven” the url is /?land=all.

    It seems to work properly, but I need to test it a little bit more. Because the string isn’t empty I guess I don’t need to unset the query anymore?

    Thanks again!! And hopefully you can confirm my code above is properly and so the form is finished 🙂

    Thread Starter edow

    (@edow)

    I made the upload function work, because I added enctype="multipart/form-data" to the form. I still have the problem that I can’t delete the avatar frontend.

    Does anyone have a suggestion what I could do wrong?

    Thread Starter edow

    (@edow)

    As you suggested I tried the hidden field option.

    <input type="hidden" name="paged" value="1">

    This works for me.

    Before that I made a special sidebar function for the 404.php page, but that isn’t necessary anymore it seems. It was this code:

    $tag = $_GET["tag"];
    $land = $_GET["land"];
    $provincie = $_GET["provincie"];
    
    if (!empty($tag)) {
    	$showSidebar = 'category';
    	}
    elseif (!empty($land)) {
    	$showSidebar = 'category';
    	}
    elseif (!empty($provincie)) {
    	$showSidebar = 'category';
    	}
    else{
    	$showSidebar = '';
    	}
    
    get_sidebar($showSidebar);

    So, that problem is now solved.

    The last problem with this form is that when I want to show for example all the countries (“land”) I need the string ?land= to disappear from the url.

    I thought it to do like this:

    <input type="radio" name="land" value=""> Show all<br>

    but that doesn’t work. With the tag it already does automatically, but it isn’t working for other keys. The url becomes /?land and the checkbox isn’t checked. So, or the string needs te be removed from the url (so it doesn’t filter and thus shows all the countries) or the string needs to be /?land=all and then the query needs to show all the countries.

    How can I handle this?

    Thread Starter edow

    (@edow)

    I’ll try what you suggested. In the meanwhile I found at that if the permalink settings are default, like /?cat=1 and I’m on page 2 (/?cat=1&paged=2) and I click on a tag the page goes to the page /?tag=example-tag. But when the permalink settings are /%postname%/ then the 404 error occurs.

    The 404 error redirects to the 404 page. When I put the form code in the normal sidebar (sidebar.php) and I remove the tag which causes the error the page redirects back to the results on page 2 (because in the url the link is still /cat/activiteit/page/2/?land=nederland (for example.)

    To let this setup work correctly I need to know how to remove the ?land= and ?provincie= string from the parameter, because then it’s working I think.

    So, the 404 error occurs because of there are not enough search results for page 2.

    I’ll try what you suggested and come back here when I found out more.

    Thread Starter edow

    (@edow)

    Indeed I use the previous_posts_link and the next_posts_link links.
    I think I wasn’t clear about it, but these buttons do take the URL parameters to the next page (my example was wrong).

    I’ve tested it a little bit more and now I it does this (there are 9 posts per page):

    1. With more then 9 posts I use the next_posts_link link and it takes the URL parameter to the next page and that’s working good.
    2. When I’m on page 2 and I click on the “land” with value “Nederland” it filters, because there are 10 “lands” with the value “Nederland”, but it shows on page 2 the 10th post (and it shows the previous_posts_link), so I think that’s why on page 2 with 9 posts or less with a certain value it gives the 404 error.
    3. When I click on a value with for example 2 posts attachted to it (when I’m on page 2) I get the 404 error.

    So, when I’m on the page /cat/activiteit/page/2/ and I start to filter and there are enough posts it’s working, but it shows the last posts and you need to click on the previous link to see the rest. And if there are for example 2 posts it gives the 404 error.

    Thread Starter edow

    (@edow)

    I tried the code from http://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination as you suggested, but with no luck.

    In functions.php I added 'posts_per_page' => 9, but also without luck.

    The last thing I tried was adding this in functions.php:

    if ( $query->is_main_query()){
    		  $query->set('posts_per_page', 9);
    	  }

    But that isn’t working either. Everything is still giving 404 errors on page 2.

    This is my current code:

    In functions.php:

    /* Create URL parameter based on custom field */
    function wpa_filter_home_query( $query ){
    	if( $query->is_main_query()
        && isset( $_GET['land'] )
    	&& isset( $_GET['provincie'] ) ) {
    		$meta_query = array(
    		'relation' => 'AND',
    			array(
                    'key' => 'land',
                    'value' => array( $_GET['land'] )
                ),
    			array(
                    'key' => 'provincie',
                    'value' => array( $_GET['provincie'] )
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    	elseif( $query->is_main_query()
    	&& isset( $_GET['land'] ) ) {
            $meta_query = array(
    			array(
                    'key' => 'land',
                    'value' => array( $_GET['land'] )
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    	elseif( $query->is_main_query()
    	&& isset( $_GET['provincie'] ) ) {
            $meta_query = array(
    			array(
                    'key' => 'provincie',
                    'value' => array( $_GET['provincie'] )
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    }
    add_action( 'pre_get_posts', 'wpa_filter_home_query' );

    In the sidebar:

    <form name="tags" onChange="document.forms.tags.submit();">
    		<?php
    		if (is_category()){
    		  $cat = get_query_var('cat');
    		  $yourcat = get_category ($cat);
    		}
    		$tag_IDs = array();
    		query_posts('category_name='.$yourcat->slug);
    		if (have_posts()) : while (have_posts()) : the_post();
    		  $posttags = get_the_tags();
    		  if ($posttags):
    			foreach($posttags as $tag) {
    			if (!in_array($tag->term_id , $tag_IDs)):
    			   $tag_IDs[] = $tag->term_id;
    			   $tag_names[$tag->term_id] = $tag->name;
    			   $tag_slug[$tag->term_id] = $tag->slug;
    			 endif;
    			}
    		  endif;
    		endwhile; endif;
    		wp_reset_query();
    
    		if (!empty($tag_IDs)){
    			echo '<h3>Het meest geschikt voor</h3>';
    			echo "<input type=\"radio\" name=\"tag\" value=\"\"> Alles weergeven<br>";
    		}
    		foreach($tag_IDs as $tag_ID){
    			$checked = $tag_slug[$tag_ID];
    			echo '<input type="radio" name="tag" value="'.$checked.'"' ;
    			if((isset($_GET["tag"])) && $_GET["tag"] == $checked) {
    			echo ' checked="checked"';
    			}
    			echo '> '.$tag_names[$tag_ID].'<br>';
    		}
    		?>
    
    		<div class="margin25px"></div>
    
    		<h3>Land</h3>
    			<input type="radio" name="land" value=""> Alles weergeven<br>
    			<input type="radio" name="land" value="nederland" <?php if((isset($_GET["land"])) && $_GET["land"] == "nederland") { echo "checked";}?>> Nederland<br>
    			<input type="radio" name="land" value="belgie" <?php if((isset($_GET["land"])) && $_GET["land"] == "belgie") { echo "checked";}?>> Belgie
    
    		<div class="margin25px"></div>
    
    		<h3>Regio</h3>
    			<input type="radio" name="provincie" value=""> Alles weergeven<br>
    			<input type="radio" name="provincie" value="gelderland" <?php if((isset($_GET["provincie"])) && $_GET["provincie"] == "gelderland") { echo "checked";}?>> Gelderland<br>
    			<input type="radio" name="provincie" value="overijssel" <?php if((isset($_GET["provincie"])) && $_GET["provincie"] == "overijssel") { echo "checked";}?>> Overijssel
    		</form>

    The url on page one looks like this for example (which is working):
    /cat/activiteit/?tag=test-tag&land=nederland&provincie=overijssel

    The url on page two looks like this for example (which gives a 404 error):
    /cat/activiteit/page/2/?tag=test

    I’m very happy you take the time to help/teach me! I’m learning a lot here.

    Thread Starter edow

    (@edow)

    Hi,

    No problem and I hope you had a nice couple of days off 🙂

    If /?land= is in the url parameter then zero results are given instead of all the results, so when I click the “Show All” radio button then I need the parameter /?land= to disappear. I’ll try what you suggested.

    In the meanwhile another problem occurs 🙁
    When I’m on page 2 in the category (/page/2/) and I check something a 404 error appears. I found out I need to add the “paged” parameter to the query.
    I thought to do it like this:

    function wpa_filter_home_query( $query ){
    	$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
    	if( $query->is_main_query()
        && isset( $_GET['land'] )
    	&& isset( $_GET['provincie'] ) ) {
    		$meta_query = array(
    		'relation' => 'AND',
    			array(
                    'key' => 'land',
                    'value' => array( $_GET['land'] ),
    				'paged' => $paged
                ),
    			array(
                    'key' => 'provincie',
                    'value' => array( $_GET['provincie'] ),
    				'paged' => $paged
                )
            );
            $query->set( 'meta_query', $meta_query );

    But this still gives a 404 error on page 2 of the category.

    I also tried 'paged' => get_query_var( 'paged' ) but without succes.

    So the form is almost working as I want, but not on page 2, 3 and so on.

    Thread Starter edow

    (@edow)

    About the query from checkbox values: I figured out the relation should be AND. I didn’t know exactly what you mean with “If AND, you must step through the checkbox values with foreach(){} and build an array of arrays for ‘meta_query’ where each ‘value’ is a single checkbox value so all the arrays together have a relation of ‘AND’.”

    So, after much struggle I came with my own alternate solution:

    <?php
    function wpa_filter_home_query( $query ){
        if( $query->is_main_query()
        && isset( $_GET['land'] )
    	&& isset( $_GET['provincie'] ) ) {
            $meta_query = array(
    		'relation' => 'AND',
    			array(
                    'key' => 'land',
                    'value' => array( $_GET['land'] )
                ),
    			array(
                    'key' => 'provincie',
                    'value' => array( $_GET['provincie'] )
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    	elseif( $query->is_main_query()
    	&& isset( $_GET['land'] ) ) {
            $meta_query = array(
    			array(
                    'key' => 'land',
                    'value' => array( $_GET['land'] )
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    	elseif( $query->is_main_query()
    	&& isset( $_GET['provincie'] ) ) {
            $meta_query = array(
    			array(
                    'key' => 'provincie',
                    'value' => array( $_GET['provincie'] )
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    }
    add_action( 'pre_get_posts', 'wpa_filter_home_query' );
    ?>

    I’m not sure why it’s working, but it looks like it is working alright. Is this a proper solution or shouldn’t I use it in this way?
    With this code I can also filter on “land” and “provincie” separately.

    If it’s alright, then my next problem is that I want to remove the parameter /?land= if I check “Show All”. When there’s /?land= in the parameter it isn’t filtering properly.

    Thread Starter edow

    (@edow)

    With one array it works when I click on “provincie” without the need of selecting something else.

    function wpa_filter_home_query( $query ){
        if( $query->is_main_query()
        && isset( $_GET['provincie'] ) ) {
            $meta_query = array(
    			array(
                    'key' => 'provincie',
                    'value' => array( $_GET['provincie'])
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    }
    add_action( 'pre_get_posts', 'wpa_filter_home_query' );
    Thread Starter edow

    (@edow)

    I see I didn’t test it well enough. It looks like it only works when “land” and “provincie” are both checked, just like you said. Then it is filtering the post whith a specific “land” AND “provincie” (also when a tag is checked). But when I only check “land” or “provincie” (even when a tag is checked) it isn’t filtering (only the checked tag is).

    So, if I check one tag it works. But if I only check “land” or “provincie” the query isn’t filtering. I need it to work all together (that is already working), but also everything separately.

    'compare' => 'IN' isn’t working either. I’m not sure how to use the AND function yet, but I’ll give it a try.

    This it how it looks like (without any checkes): http://oi58.tinypic.com/2wp05km.jpg.
    The url parameter then is (if I check it): /?tag=test&land=nederland&provincie=overijssel (this works).

    But when it is /?land=nederland OR /?provincie=gelderland it isn’t working.

    So, when “land” and “provincie” are filtering independently it should work, but right now they’re filtering when one another or a tag is checked.

    Thread Starter edow

    (@edow)

    I think I have the solution for the creating of the url paramter based on multiple custom fields. It looks like this code is working fine:

    function wpa_filter_home_query( $query ){
        if( $query->is_main_query()
    	&& isset( $_GET['land'] )
        && isset( $_GET['provincie'] ) ) {
            $meta_query = array(
                array(
                    'key' => 'land',
                    'value' => array( $_GET['land'])
                ),
    			array(
                    'key' => 'provincie',
                    'value' => array( $_GET['provincie'])
                )
            );
            $query->set( 'meta_query', $meta_query );
        }
    }
    add_action( 'pre_get_posts', 'wpa_filter_home_query' );

    It’s another approach then you suggested, but I thought I’ll give it a try.

    Thread Starter edow

    (@edow)

    Thanks for your help again!

    If I use this code:

    foreach($tag_IDs as $tag_ID){
    			$checked = $tag_slug[$tag_ID];
    			echo '<input type="checkbox" name="tag[]" value="'.$checked.'"' ;
    			if((isset($_GET["tag"])) && $_GET["tag"] == $checked) {
    			echo ' checked="checked"';
    			}
    			echo '> '.$tag_names[$tag_ID].'<br>';
    		}

    I get this url paramter:

    /?tag%5B%5D=test

    and then there’re no search results. Also the checkboxes aren’t checked anymore.

    When I have more time I’ll look after your other answers and post my results here.

Viewing 15 replies - 16 through 30 (of 63 total)