Help with if/else loop [closed]

You arent clear where you want your else statement, so Ive added one for each of the if’s you included. <?php $post_type=”post”; // <– Post Type $tax = ‘temporada’; // <– Taxonomía $termino = get_terms($tax); $category = get_the_category(); $cat_name = $category[0]->cat_ID; if ($termino) { foreach ($termino as $temporada) { $args=array( ‘post_type’ => $post_type, “$tax” => … Read more

Woocommerce linking variations

I found a solution with a recursive function function decomposePrice($base, $iValue, $values, $prices) { $d = array(); foreach ($prices as $i => $p) { $baseP = “$base{$values[$iValue][$i]}|”; if (!is_array($p)) { $d[$baseP] = $p; } else { $d = array_merge($d, decomposePrice($baseP, $iValue + 1, $values, $p)); } } return $d; } $decomposePrice = decomposePrice(“”, 0, $v_values, … Read more

One folder to be accessible by one user

One solution might be to directly restrict access to the file on the server, but utilize a url rewrite to display the content — only if the id matches in the request. Obviously this doesn’t answer every question in the scenario but it does provide a proof-of-concept to indirectly convert a url into a file. … Read more

How make wp_nav() with my css?

First step is to register the name (or names) for your menus. In your example, top-nav seems appropriate. function vd_register_menu() { register_nav_menu(‘top-nav’,__( ‘Top Nav Menu’ )); } add_action( ‘init’, ‘vd_register_menu’ ); This will allow you to build your menu items in the WP admin under Appearance > Menus. To display your menu on the site, … Read more

How to create a loop that will display one post and stop?

query_posts() can alter the WP query even when it is executed and it should be placed at least before you start the loop i.e. have_posts(). Currently you are placing it after setting up post data i.e. the_post(). Which is resulting in unexpected behavior. Example: global $query_string; //Get current query arguments query_posts($query_string.”&featured=yes”); if (have_posts()) { while … Read more

How to create a loop where loop changes every post?

The PHP modulus operator gives you the remainder from dividing 2 numbers. The remainder from the division of any number by two is either 0 or 1, so we can use that to provide an “alternator”. We use the current_post var as a counter, which is available in any WP_Query object: while( have_posts() ){ the_post(); … Read more

True or False: Is an Apache error or PHP error the same as a WordPress error?

WordPress errors are application level errors. PHP errors are language syntax or usage errors and appach error are errors detected during the web server operation. Errors, especially minor ones, might be reported “upwards” and look like they are wordpress application errors, or logged downwards and be part of the apache server error log if the … Read more