how to loop through blog posts in php

$args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ); $the_query = new WP_Query( $args ); If you set the posts_per_page to -1 it will return all posts. Then you can loop through and do what you want with the single post. while ( $the_query->have_posts() ) { echo get_the_author_meta( );//I have NOT used this so … Read more

Header location [closed]

HTML code: <h4 id=”yourId”><span><strong>100%</strong></span></h4> CSS: code #yourId { position: top: 10px; right: 10px; position: absolute; } If you need it to stay always there even if you’re scrolling then use this one #yourId { position: top: 10px; right: 10px; position: fixed; }

metabox displaying on incorrect page

Dropping the code quickly into my test set up, I think you are asking why your page metabox is showing your desired post meta inputs. There’s no problem with your add_meta_box() functions. The problem is with your variable $custom_meta_fields. By the time WordPress gets to the end of your file $custom_meta_fields is defined by the … Read more

How to implement a custom sliding banner? [closed]

There are a lot of slider pluglins in wordpress repository such http://wordpress.org/plugins/slide-show-pro/, just follow the install steps. then use the shortcodes like [slideshowpro cats=2,3] or the code to integrate into php php echo do_shortcode(‘[slideshowpro cats=2,3]’); insert the code in header.php to show the slider on every single page or post

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