create functions based on array values

Can you use the __call PHP class functionality? http://www.php.net/manual/en/language.oop5.overloading.php#object.call You could use __call in your class and call your function for grabbing the page types and check them against the $name (first) argument and running custom code against it. For instance: __call ($name, $args) { $types = array (‘type_a’, ‘type_b’, ‘type_c’); if (in_array($name, $types) { … Read more

Insert dynamic content into posts

Everytime you upload a new image, the afip_new_post_content filter is called which can be used to change the post content before creation – http://wordpress.org/extend/plugins/automatic-featured-image-posts/ Assuming you have a list of URLs stored somewhere – like in the database – you need a function that would get a url from this list, then delete the url … Read more

posting twice from an array?

You could try something like this: $postTitle=””; // save post title if(isset( $_POST[‘submit’])){ // if submit button is present $vergoeding=$_POST[‘vergoeding’]; $extrakosten=$_POST[‘extrakosten’]; for ($i=0; $i < count($vergoeding); $i++) { $new_post = array( ‘post_title’ => $postTitle, ‘post_content’ => ‘ ‘, // can not be empty ‘post_status’ => ‘publish’, ‘post_type’ => ‘landschapselement’ // custom post type ); $pid … Read more

shortcodes inside shortcode to sum values

You can try this: add_shortcode(‘sumsc’,’sumsc_func’); function sumsc_func( $atts, $content = null ) { $sum=0; preg_match_all(‘/stat([0-9]+)/i’, $content, $matches); if(isset($matches[1])){ $sum = array_sum($matches[1]); } return do_shortcode($content).” <div>The sum is <strong>”.$sum.”</strong></div>”; } This will add the total sum at the end of the shortcode content. Usage example: You can try this in your editor: [sumsc][stat1 val=”usa”] [stat2 val=”europe”] … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)