How to automatically create a custom field when a post is published?
add_action(‘publish_post’. ‘add_custom_field_automatically’); You have a period in the second add_action. This should be a comma 🙂
add_action(‘publish_post’. ‘add_custom_field_automatically’); You have a period in the second add_action. This should be a comma 🙂
Well I don’t know anything about genesis, but if it does indeed use WP_Query args, then your args array should be something like: $args = array( ‘post_type’ => ‘artists’, ‘meta_key’ => ‘ecpt_featured_artist’, ‘meta_value’ => 1, );
You can find out the post format using get_post_format(). So try adding your textarea custom field in a custom metabox library file, and then do the following: if( ‘video’ == get_post_format( $post->ID ) ) { include_once( get_stylesheet_directory_uri() . ‘/path-to-cmb-library/video-metabox-file.php’ ); } This assumes that you’re in The Loop or that you have a WordPress Post … Read more
You almost gave the answer yourself :o) replace ‘custom’ => serialize( array( $order_id, $order->order_key ) ), with ‘custom’ => ‘yourword’, and you’re done!
removed printf <?php if ( get_post_meta($post->ID, ‘test_field’, true) ) { echo do_shortcode(‘[shortcode]’. get_post_meta($post->ID, “test_field”, true) . ‘[/shortcode]’); } ?>
This is pretty wonky (I would never do it), but it should work if you access the global. global $post; $image = get_post_meta( $wp_query->post->ID, ‘img’, true); <img src=”https://wordpress.stackexchange.com/questions/105398/<?php echo $image; ?>” class=”img”/>
function to handle to show file size i.e. paste this code in functions.php /* * @param string $fileSize Filepath * @param int $digits Digits to display * @return string|bool Size (KB, MB, GB, TB) or boolean */ function getFilesize($fileSize, $digits=2) { $sizes = array(“TB”,”GB”,”MB”,”KB”,”B”); $total = count($sizes); while ($total– && $fileSize > 1024) { $fileSize … Read more
Adding additional fields to comments isn’t hard. There are tons of decent tutorials out there (and probably prebuilt plugins too). Google it. Here’s an example: http://wp.smashingmagazine.com/2012/05/08/adding-custom-fields-in-wordpress-comment-form/ As far as I know, searching on tags + categories + comments isn’t possible. I’m confused on why you’d want to search on comments?
Because you’re in The Loop, you shouldn’t need to use get_the_ID(). Does this: <div class=”latest”> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class=”boxes”> <?php echo “<p>”.the_meta().”</p>”; ?> <a href=”https://wordpress.stackexchange.com/questions/109423/<?php echo get_post_meta($post->ID,”promotional_link’, true); ?>”> <?php //var_dump($show); ?> <img src=”<?php echo get_post_meta( $post->ID, ‘promotional_image’, true); ?>” height=”200″ width=”260″> </a> </div><!–boxes–> … Read more
There are several examples on the net, however I use this: <?php //functions.php add_filter( ‘widget_text’, ‘php_parser’, 100 ); function php_parser( $html ){ if( strpos( $html, “<“.”?php” ) !== false ){ ob_start(); eval( “?”.”>”.$html ); $html = ob_get_contents(); ob_end_clean(); } return $html; } ?>