How to reset the plugins without deactivate the plugin

You could make another function with will (re)set the default option values: function wpse_91307_set_option_defaults() { $options = array( ‘ptechsolcopy_notice’ => ‘Copyright ©’, ‘ptechsolcopy_reserved’ => ‘All Rights Reserved’ ); foreach ( $options as $option => $default_value ) { if ( ! get_option( $option ) ) { add_option( $option, $default_value ); } else { update_option( $option, $default_value … Read more

Functions Error: Impacting Galleries

You can try to add the condition $query->is_main_query() in your if-sentences so it won’t affect the gallery queries: // Posts per page add_filter(‘parse_query’, ‘wpq_parse_query’); function wpq_parse_query($query) { if(!$query->is_main_query()) { return $query; } if($query->is_archive()) { $query->query_vars[‘posts_per_page’] = get_option(‘to_count_archives’, 1); } if($query->is_home()) { $query->query_vars[‘posts_per_page’] = get_option(‘to_count_home’, 1); } if($query->is_search()) { $query->query_vars[‘posts_per_page’] = get_option(‘to_count_search’, 1); } return $query; … Read more

Countdown to date function?

You can use the following function to display it <?php function days_to_go(){ $datetime1 = new DateTime(‘2013-3-2’);//Pass resignation date as a parameter. $datetime2 = new DateTime(now); $interval = $datetime1->diff($datetime2); echo $interval->format(‘%a days to go’); } ?> For more information on date_diff function see this page.

wordpress get_post_meta give only first value

You have the parameter of get_post_meta set to true which returns single result, set it to false or remove it completely. $dump_array = get_post_meta(get_the_id(), ‘_as_roomname’) //check whats in the array var_dump($dump_array); // or loop for output foreach( $dump_array as $dump ) echo $dump;

How to use a variable as a function name?

<?php $numcpost = of_get_option(‘how_many_custom_posts’); do { add_action( ‘init’, ‘register_cpt_mdframework_price’, $numcpost ); –$numcpost; } while ( $numcpost > 0 ); function register_cpt_mdframework_price( $numcpost ) { $singcpost = of_get_option(‘custom_posts_name_s_n’.$numcpost.”); $plurcpost = of_get_option(‘custom_posts_name_p_n’.$numcpost.”); $desccpost = of_get_option(‘custom_posts_name_d_n’.$numcpost.”); $imgcpost = of_get_option(‘custom_posts_name_i_n’.$numcpost.”); $labels = array(); // labels for $numcpost = 1 $labels[1] = array(/*typo was here*/ ‘name’ => _x( $plurcpost, ‘mdframework_custom_created_post’.$numcpost.” … Read more

Theme not calling Jquery properly

If you register a script with wp_register_script() it is not neccessary to pass all the options in wp_enqueue_script() again. You can register the script in a central place and use the enqueueing it in diffenrent files. functions.php wp_register_script( ‘theme_script’, ‘path/to/script.js’, array( [dependencies] ), ‘1.0’, true ); […] if ( $condition ) require_once ‘file1.php’; else require_once … Read more

Custom HTML markup

Put this in your functions.php: add_shortcode(‘my_blockquote’, ‘my_blockquote’); function my_blockquote($atts, $content) { return ‘<div class=”span3 quote well”>’.PHP_EOL .'<i class=”icon-quote-left icon-2x pull-left icon-muted”></i>’.PHP_EOL .'<blockquote class=”lead”>’.$content.'</blockquote>’.PHP_EOL .'</div>’; } Then, on a page/post, just write: [my_blockquote]Content goes here…[/my_blockquote] and that’s it. // EDIT: To add a quicktag button, put this also in functions.php: function add_blockquote_quicktag() { ?> <script type=”text/javascript”> … Read more

Get post meta retrieving wrong value

Please take some time to read the Codex. the_ID echos content. That means that the ID is never being passed to get_post_meta. It is just echoed in place. From the same Codex Page: Note: This function displays the ID of the post, to return the ID use get_the_ID(). So, use get_the_ID instead. Second problem… quote … Read more

How to create a functions.php in child theme? [closed]

You need to remove the space between <? and php at the very start of your file. Incorrect: <? php add_action(‘iphorm_post_process_1’, ‘mytheme_create_wp_post’, 10, 1); function mytheme_create_wp_post($form) { Correct: <?php add_action(‘iphorm_post_process_1’, ‘mytheme_create_wp_post’, 10, 1); function mytheme_create_wp_post($form) { This is causing a simple syntax error.