Does WordPress Loop have a function like Shopify’s cycle?

Short answer, no. But that is a pretty cool feature! To so something similar in WordPress, you’d need to code some kind of iterator in PHP and have it do the logic for you. For example: $classes = array( ‘first’, ‘second’, ‘third’ ); $iteration = 0; if ( have_posts() ) : while ( have_posts() ) … Read more

How to exclude visited posts from loop

This is a heavier question than you think. You’ll need to do quite a bit: Set a cookie in the user’s browser to keep track of the posts they’ve seen. Pull data out of that cookie to get a list of post IDs Add this to the array with the $featured_post_id to pass it in … Read more

Listing Specific Categories from Current Post with Depth

This takes all the categories associated with your post and checks if they are parents of anything else. If one is not, it is the lowest category and is echoed out. <?php $postCats = wp_get_post_categories(); foreach($postCats as $childcat) { //this is a top level category if ($childcat->category_parent==0) { continue; } for ($J=0;$J<sizeof($postCats);$J++) { //if another … Read more

need help looping add_action in wp

You can try something like this: $dynValue=5;//loop this many times //start of my loop for ($num=1; $num <= $dynValue; $num++){ add_action(‘add_meta_boxes’, create_function(”, ‘//some content’)); // Write the php code as if it was to put it in an echo/print instruction. // More details: http://php.net/manual/en/function.create-function.php }//end of my loop