0

I'm using Woocommerce and its atributes (custom taxonomies). I have some pages which I query this way:

http://example.com/?tax1=term1&tax2=term2

This query gives me the posts from taxonomy 1 and taxonomy 2 that matches term1 and term2. I'd like to insert some text on these pages. Any way to accomplish this?

Thank you

  • Do you want to insert the text on the fly or write it to the DB permanently? Where do you want to insert it - i.e. do you know how you want to identify the position? – Johannes Pille Oct 2 '12 at 17:00
  • I'm haven't thought about the database thing. I guess that shouldn't be a problem, since I could edit the text on the DB. So, whatever you think is best. Position would be in the Woocommerce "products" loop: do_action('woocommerce_before_shop_loop'); ?> <ul> </ul> <?php do_action('woocommerce_after_shop_loop'); ?> – Marce Castro Oct 2 '12 at 20:51
  • 2
    If you had figured out solution yourself please consider adding it as an answer so others can learn from it. – Rarst Oct 18 '12 at 11:05
0

Ok, but I was afraid it's not really a good solution. Works, though.

First, I rewrote the query in order to get pretty permalinks:

 /*Añadido: Reescribir URL query: "?pa_dispositivo=nombre&pa_marca=nombre"*/
function custom_rewrite( $wp_rewrite ) {

    $feed_rules = array(
        'tipo/(.+)/marca/(.+)'    =>  'index.php?pa_dispositivo='. $wp_rewrite->preg_index(1).'&pa_marca='. $wp_rewrite->preg_index(2)
        //'(.+)'    =>  'index.php?pa_marca='. $wp_rewrite->preg_index(1)
        //'(.+)'    =>  'index.php?pa_dispositivo='. $wp_rewrite->preg_index(1)
    );

    $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
}
// refresh/flush permalinks in the dashboard if this is changed in any way
add_filter( 'generate_rewrite_rules', 'custom_rewrite' );

/*Fin Añadido*/

This gives me something like site.com/name/tax1/name2/tax2.

Then, I modified the file that creates the divs contaning the query results. If the URL is "this" do echo "that":

$uri = $_SERVER['REQUEST_URI']; //Sacamos la URL y los fragmentos de la URL
    $pieces = explode("/", $uri);
    $uri_prov= $pieces[2];  

    echo "<div class='breadcrumbsBusqueda'>";

    switch ($uri) {

        case "/provincia/".$uri_prov."/":
        echo "<a href='/'>Inicio</a> › ".$uri_prov."</div>TEXT<div class='area_with_sidebar area_left'>";
        break;

        default:        
        echo '<a href="/">Inicio</a> › Esto es lo que hemos encontrado para tu búsqueda: '.get_search_query().'</div><div class="area_with_sidebar area_left">'



        //add as many cases as you need
  • No need to add (Solved) to title, just mark question as accepted and you're good to go... – userabuser Oct 18 '12 at 15:18
  • Ok. Sorry about that. I'm posting on so many forums that sometimes I get a little confused :-/ Answer accepted. – Marce Castro Oct 19 '12 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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