How to put a variable in a instance in the widget

As far I understood you want to assign the order number like $order_number = order_generator($email) inside the widget class. Yes, you can do it that way unless the order_generator is in another class. If you order_generator function is in another class then first you need to instantiate the class then call the method like $instance_of_your_class->order_generator($email). … Read more

Problem when linking out to separate file within foreach loop

As far I’ve known get_template_part() function does not work with foreach loop. So we need to use locate_template() function to this case. This is your customized category template code. Put it there – <?php /** * Category Template: Custom */ get_header(); ?> <div id=”content” class=”site-content container <?php echo codilight_lite_sidebar_position(); ?>”> <div class=”content-inside”> <div id=”primary” class=”content-area”> … Read more

Cannot display or echo alt text on featured image

I am not so sure of what I am going to say, but from a fast look, $featured_image is an array (URL, width, height, is_intermediate). so assuming that your alternative text exists in this array, you need to specify its index like this: $featured_image[index_of_alt_text] according to my understanding, the $featured_image array doesn’t contain your alternative … Read more

Using foreach loop breaks

I believe your issue is with $vals=get_post_meta($post_id, $key2, true); If you check the codex, the last parameter for get_post_meta is whether to return a single value or array of values. You have set it to true which means return only one value. Try it with false (the default) it should work.

Only echo item in foreach with highest value [closed]

Technically, this is more of a general PHP question rather than a WordPress question which should be on Stack Overflow instead. To echo only the highest value from your array, try storing your items ($s[1]) into an array instead and then use max(). Something like this: $args = array( ‘post_type’ => array(‘product’), ‘posts_per_page’ => -1 … Read more

my posts are saved as drafts

You simply need to copy the current function sanitize_title_with_dashes from https://core.trac.wordpress.org/browser/tags/4.6/src/wp-includes/formatting.php#L1948 and change the following line: $title = utf8_uri_encode($title, 200); To this: $title = utf8_uri_encode($title, 1000); Minor edit: Always refer to the source for the same version of WordPress you have installed. In most cases, it should be the current version. The script you are … Read more