Get post thumbnail from subpages with a foreach loop
Life can be simple: Instead of the_post_thumbnail I should use get_the_post_thumbnail echo get_the_post_thumbnail($page->ID)
Life can be simple: Instead of the_post_thumbnail I should use get_the_post_thumbnail echo get_the_post_thumbnail($page->ID)
To start with, you need to fix the define of CSV_PATH: define(‘CSV_PATH’,dirname(__FILE__)); as without that, $handle will be false – no file opened or data read. …then before you run it take another look becaue $col4 and $col5 are not set anywhere either…
I used this to show images on slider .Try this <div class=”col-md-12″> <div class=”carousel carousel-showmanymoveone slide” id=”carousel123″> <div class=”carousel-inner”> <div class=”item active”> <div class=”col-xs-12 col-sm-6 col-md-3″> <img src=”https://wordpress.stackexchange.com/questions/217614/<?php echo plugin_dir_url( __FILE__ ) .”img/download-1.jpg’; ?>”></div> </div> <div class=”item”> <div class=”col-xs-12 col-sm-6 col-md-3″> <img src=”https://wordpress.stackexchange.com/questions/217614/<?php echo plugin_dir_url( __FILE__ ) .”img/download-1.jpg’; ?>”></div> </div> <div class=”item”> <div class=”col-xs-12 col-sm-6 … Read more
You can use the action hook save_post_{post_type}, so for the post type ‘post’ (blog posts) it is: save_post_post. For more info see the codex. add_action( ‘save_post_post’, ‘sw150216_save_reading_time’, 10, 3); function sw150216_save_reading_time( $post_id, $post, $update ) { $reading_time = estimated_reading_time( $post ); if ( $update ) { update_post_meta ( $post_id, ‘reading_time’, $reading_time ); } else { … Read more
You only need to register one setting and then just modify your form inputs to save the values into an array. Here’s an example of registering the setting: register_setting( ‘mytheme_settings’, ‘mytheme_settings’, ‘admin_options_sanitize’ ); $mytheme_settings = get_option( ‘mytheme_settings’ ); and the field markup: <textarea name=”mytheme_settingsAdmin Options page. Save as Array”> <?php echo esc_textarea( $mytheme_settings[‘title’] ); ?> … Read more
About your issue in admin body class, WP Codex documentation admin_body_class, class as string ( not array ), there are some of your function like get_saved_network_option not returning true that cause $new_classes not setted in array. This code correct, we need return in string, but $new_classes maybe in string empty or not array. return $body_classes … Read more
Although @Jevuska did solve my issue, I have found a much easier solution to adding dynamic CSS from my theme options page. Here we go! Add this to functions.php add_action(‘wp_head’, ‘my_custom_css’); function my_custom_css(){ require_once( get_template_directory() . ‘/css/theme-styles.php’ ); } Now you can treat theme-styles.php as a normal CSS stylesheet <style type=”text/css”> a { color: <?php … Read more
By default WP is very reluctant to show or display any errors. That’s inline with its strategy of “dumbing down” things of sorts. The configuration I use to monitor for errors is along the lines of this in wp-config.php: define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_DISPLAY’, false ); @ini_set( ‘display_errors’,’Off’ ); @ini_set( ‘log_errors’,’On’ ); @ini_set( ‘error_log’,’/home/user/logs/php_site_name.log’ … Read more
Sorry to come to the party late. Here is my solution <?php //Retrieve the terms in productcategory taxonomy with posts (not empty) $terms = get_terms( array ( ‘taxonomy’ => ‘productcategory’, ‘hide_empty’ => false, ‘parent’ => 0, ‘orderby’ => ‘description’, ‘order’ => ‘ASC’ )); //loop through each term to get its attributes foreach ($terms as $term) … Read more
The direct answer to the question “Is there a way to get 3+ dimensional array from a single MySql command” would be yes, sort of – WordPress routinely stores and retrieves multidimensional data from MySQL rows by serialize()ing and unserialize()ing structured data to/from a string format, so it’s certainly possible using WordPress’s database interaction mechanisms. … Read more