本文整理汇总了PHP中get_custom_field函数的典型用法代码示例。如果您正苦于以下问题:PHP get_custom_field函数的具体用法?PHP get_custom_field怎么用?PHP get_custom_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_custom_field函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shortcode_output
/**
* Output for Shortcode
*
* @since 1.1.9
*
* @param $atts
*
* @return mixed|null
*/
function shortcode_output($atts)
{
$default_atts = array('key' => '', 'field' => '', 'job_id' => get_the_ID());
$merged_atts = array_merge($default_atts, $atts);
try {
// Attributes
$args = shortcode_atts($merged_atts, $atts, 'jmfe');
if (empty($args['key']) && empty($args['field'])) {
throw new Exception(__('Meta Key was not specified!', 'wp-job-manager-field-editor'));
}
if (empty($args['job_id'])) {
throw new Exception(__('Unable to determine correct job/resume/post ID!', 'wp-job-manager-field-editor'));
}
if ($args['key']) {
$meta_key = $args['key'];
}
if ($args['field']) {
$meta_key = $args['field'];
}
$post_meta = get_custom_field($meta_key, $args['job_id'], $args);
if (is_array($post_meta)) {
$post_meta = implode(', ', $post_meta);
}
return $post_meta;
} catch (Exception $error) {
error_log('Shortcode output error: ' . $error->getMessage());
}
}
示例2: widget
function widget($args, $instance)
{
extract($args);
echo $before_widget;
echo $before_title . 'Active Projects' . $after_title;
$order = array('Dev', 'Maintenance', 'Edit', 'Design', 'Dev Complete', 'Project Complete');
echo '<ol>';
foreach ($order as $order_item) {
global $prefix;
$args = array('category_name' => 'active-project', 'posts_per_page' => '-1', 'meta_query' => array(array('key' => $prefix . 'project_status', 'value' => $order_item)));
$active = new WP_Query($args);
global $prefix;
$prefix = '_crm_';
while ($active->have_posts()) {
$active->the_post();
global $post;
$project_name = get_custom_field($prefix . 'project_name');
if (!empty($project_name)) {
$name = $project_name . ' (' . get_the_title() . ')';
} else {
$name = get_the_title();
}
?>
<li><a href="<?php
the_permalink();
?>
"><?php
echo $name;
?>
</a> <?php
edit_post_link('Edit', '(', ')');
?>
<br />
<?php
$status_summary = get_custom_field($prefix . 'status_summary');
$status = get_custom_field($prefix . 'project_status');
if (!empty($status)) {
echo '<strong>Status:</strong> ' . $status;
}
if (!empty($status_summary)) {
echo ' | ' . $status_summary;
}
if (!empty($status) || !empty($status_summary)) {
echo '<br />';
}
$started = get_custom_field($prefix . 'start_date');
if ($started) {
echo '<strong>Started:</strong> ' . date('F j, Y', strtotime($started)) . ',';
}
$revenue = get_custom_field($prefix . 'revenue');
$expense = get_custom_field($prefix . 'expense');
if ($revenue) {
echo 'Budget: $' . number_format($revenue - $expense) . '</li>';
}
}
}
echo '</ol>';
wp_reset_query();
echo $after_widget;
}
示例3: be_complete_loop
function be_complete_loop()
{
do_action('genesis_before_post_title');
do_action('genesis_post_title');
do_action('genesis_after_post_title');
global $prefix;
$args = array('category_name' => 'complete', 'posts_per_page' => '20', 'meta_query' => array(array('key' => $prefix . 'include_complete')));
$complete = new WP_Query($args);
setlocale(LC_MONETARY, 'en_US');
$loop_counter = 0;
while ($complete->have_posts()) {
$complete->the_post();
$revenue = get_custom_field($prefix . 'revenue');
$expense = get_custom_field($prefix . 'expense');
$profit = $revenue - $expense;
$time = get_custom_field($prefix . 'time_setup') + get_custom_field($prefix . 'time_development') + get_custom_field($prefix . 'time_phone') + get_custom_field($prefix . 'time_hourly') + get_custom_field($prefix . 'time_other');
if ($time) {
$rate = money_format('%(#10n', $profit / $time);
}
if (!empty($revenue)) {
$revenue = money_format('%(#10n', $revenue);
}
if (!empty($expense)) {
$expense = money_format('%(#10n', $expense);
}
if (!empty($profit)) {
$profit = money_format('%(#10n', $profit);
}
if ($loop_counter % 3 == 0) {
echo '<div class="first project">';
} else {
echo '<div class="project">';
}
echo '<h3><a href="' . get_edit_post_link() . '">' . be_get_project_name() . '</a></h3>';
echo '<p>';
if ($revenue) {
echo '<strong>Budget</strong>: ' . $revenue;
if ($expense) {
echo ' - ' . $expense . ' = ' . $profit;
}
echo '<br />';
}
if ($time) {
echo '<strong>Time Spent:</strong> ' . $time . ' hrs <br /><strong>Effective rate:</strong> ' . $rate . ' /hr<br />';
}
echo '</p>';
echo '</div>';
$loop_counter++;
}
}
示例4: widget
function widget($args, $instance)
{
extract($args);
echo $before_widget;
echo $before_title . 'Active Projects' . $after_title;
$active = new WP_Query('category_name=active-project&posts_per_page=-1&showposts=-1');
$count = 0;
global $prefix;
if ($active->have_posts()) {
echo '<ol>';
while ($active->have_posts()) {
$active->the_post();
global $post;
$count++;
?>
<li><a href="<?php
the_permalink();
?>
"><?php
the_title();
?>
</a> <?php
edit_post_link('Edit', '(', ')');
?>
<br />
<?php
$status = get_custom_field($prefix . 'status_summary');
if ($status) {
echo '<strong>Status:</strong> ' . $status . '<br />';
}
$started = get_custom_field($prefix . 'start_date');
if ($started) {
echo '<strong>Started:</strong> ' . date('F j, Y', strtotime($started)) . '<br />';
}
$revenue = get_custom_field($prefix . 'revenue');
$expense = get_custom_field($prefix . 'expense');
if ($revenue) {
echo '<strong>Budget:</strong> $' . number_format($revenue - $expense) . '</li>';
}
}
if ($count < 1) {
echo "<p>Don't worry. I'm sure a few of those prospects listed in the left column will make the jump over here soon.</p><p>Or, maybe you haven't set up your categories yet. This area shows posts in the Active Projects category, so create a category with a slug 'active-project'.</p>";
}
echo '</ol>';
} else {
echo "<p>Don't worry. I'm sure a few of those prospects listed in the left column will make the jump over here soon.</p><p>Or, maybe you haven't set up your categories yet. This area shows posts in the Active Projects category, so create a category with a slug 'active-project'.</p>";
}
wp_reset_query();
echo $after_widget;
}
示例5: display_build_profiles
function display_build_profiles()
{
query_posts(array('posts_per_page' => -1, 'offset' => 0, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'profile', 'post_status' => 'publish', 'suppress_filters' => true));
if (have_posts()) {
$return_string .= '<div id="profiles">';
while (have_posts()) {
the_post();
if (has_post_thumbnail($post->ID)) {
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
}
$post = get_custom_field('graduated_from:get_post');
$program_color = $post['program_color'];
list($r, $g, $b) = sscanf($program_color, "%02x%02x%02x");
$return_string .= '<div class="profiles-single"><a href="' . get_permalink() . '"><div class="profiles-thumb" style="background-image: url(' . $image[0] . ')"></div><div class="profiles-title" style="background: rgba(' . $r . ', ' . $g . ', ' . $b . ', .7);"><h2>' . get_the_title() . '</h2><h3>' . get_custom_field('associated_company') . '</h3></div></a></div>';
}
$return_string .= '</div>';
}
wp_reset_query();
return $return_string;
}
示例6: widget
/**
* Front-end display of widget (Widget Output)
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $config Saved values from database.
*/
public function widget($args, $config)
{
if (!function_exists('the_custom_field') || !function_exists('get_custom_field')) {
return;
}
if (empty($config['meta_key'])) {
return;
}
$meta_key = $config['meta_key'];
// Set output_classes key to extra_classes value to be compatible with function
$config['output_classes'] = $config['extra_classes'];
// Set output_caption = caption to be compatible with function
$config['output_caption'] = $config['caption'];
$custom_fields = $this->jmfe()->get_custom_fields(TRUE);
foreach ($custom_fields as $group => $fields) {
if (array_key_exists($meta_key, $fields)) {
$config = array_merge($custom_fields[$group][$meta_key], $config);
break;
}
}
// Exit if there is no value for field (to prevent widget output)
$field_value = get_custom_field($config['meta_key'], get_the_id(), $config);
if (empty($field_value)) {
return;
}
$widget_styles = isset($config['widget_styles']) && !empty($config['widget_styles']) ? true : false;
if ($widget_styles) {
echo $args['before_widget'];
if (!empty($config['title'])) {
echo $args['before_title'] . apply_filters('widget_title', $config['title']) . $args['after_title'];
}
}
the_custom_field($config['meta_key'], NULL, $config);
if ($widget_styles) {
echo $args['after_widget'];
}
}
示例7: get_custom_field
<!-- Blurb Generator -->
<?php
$blurbs = get_custom_field('page_blurbs');
$blurb_columns = get_custom_field('blurb_columns');
echo '<div class="container" ><div class="blurb-maker" column-rel="' . $blurb_columns . '">';
foreach ($blurbs as $blurb) {
if ($blurb['link']) {
$blurblink = '<a title="' . $blurb['title'] . '" target="_' . $blurb['target'] . '" href="' . $blurb['link'] . '" >';
$blurbspotlink = '<a class="zoom-image-wrapper" title="' . $blurb['title'] . '" target="_' . $blurb['target'] . '" href="' . $blurb['link'] . '" >';
$blurbendlink = '</a>';
} else {
$blurblink = '';
$blurbspotlink = '';
$blurbendlink = '';
}
echo '
<div class="' . $blurb_columns . ' column columns">
<div class="module-container blurb">
<div class="module">
' . $blurbspotlink . '
<img class="blurb-image zoom-image" src="' . $blurb['image'] . '" alt="' . $blurb['title'] . '" />
<div class="zoom-overlay"><div></div></div>
' . $blurbendlink . '
</div>
<div class="module-meta">
<h3 class="module-headline">' . $blurblink . '' . $blurb['title'] . '' . $blurbendlink . '</h3>
<p>' . $blurb['description'] . '</p>
</div>
</div>
示例8: aboutUs
function aboutUs()
{
get_custom_field('wpcf-about-us-home', TRUE);
}
示例9: be_active_loop
function be_active_loop()
{
echo '<div class="two-thirds first">';
$order = array('dev', 'maintenance', 'edit', 'dev-complete', 'project-complete');
setlocale(LC_MONETARY, 'en_US');
foreach ($order as $order_item) {
$loop_counter = 1;
global $prefix;
$args = array('category_name' => 'active-project', 'posts_per_page' => '-1', 'meta_query' => array(array('key' => $prefix . 'project_status', 'value' => $order_item)));
$active = new WP_Query($args);
if ($active->have_posts()) {
echo '<h2 class="first">' . ucwords($order_item) . '</h2>';
}
while ($active->have_posts()) {
$active->the_post();
$status = get_custom_field($prefix . 'project_status');
$type = get_custom_field($prefix . 'project_type');
$status_summary = get_custom_field($prefix . 'status_summary');
$revenue = get_custom_field($prefix . 'revenue');
$expense = get_custom_field($prefix . 'expense');
$profit = $revenue - $expense;
if (!empty($revenue)) {
$revenue = money_format('%(#10n', $revenue);
}
if (!empty($expense)) {
$expense = money_format('%(#10n', $expense);
}
if (!empty($profit)) {
$profit = money_format('%(#10n', $profit);
}
$work = get_custom_field($prefix . 'needs_work');
if (empty($work)) {
$work = 'yes';
}
$classes = array('project', strtolower($order_item), $work);
if ($loop_counter % 2 == 1 && $loop_counter !== '1') {
$classes[] = 'first';
}
echo '<div class=" ' . implode(' ', $classes) . '">';
echo '<h4><a href="' . get_edit_post_link() . '">' . be_get_project_name() . '</a></h4>';
echo '<p>';
echo '<strong>' . ucwords($status) . '</strong>: ' . $status_summary . '<br />';
if ($type) {
echo '<strong>Type</strong>: ' . $type . '<br />';
}
if ($revenue) {
echo '<strong>Budget</strong>: ' . $revenue;
}
if ($expense) {
echo ' - ' . $expense . ' = ' . $profit . '<br />';
}
echo '</p>';
echo '</div>';
$loop_counter++;
}
}
echo '</div><div class="one-third grey">';
echo '<h1>Scheduled Projects</h1>';
global $prefix;
$args = array('category_name' => 'scheduled-project', 'posts_per_page' => '-1', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_key' => $prefix . 'date_dev_start');
$scheduled = new WP_Query($args);
global $be_output_end;
$be_output_end = '';
while ($scheduled->have_posts()) {
$scheduled->the_post();
$output = '';
global $be_output_end;
$start = get_custom_field($prefix . 'date_dev_start');
$type = get_custom_field($prefix . 'project_type');
$status_summary = get_custom_field($prefix . 'status_summary');
$revenue = get_custom_field($prefix . 'revenue');
$expense = get_custom_field($prefix . 'expense');
$profit = $revenue - $expense;
if (!empty($revenue)) {
$revenue = money_format('%(#10n', $revenue);
}
if (!empty($expense)) {
$expense = money_format('%(#10n', $expense);
}
if (!empty($profit)) {
$profit = money_format('%(#10n', $profit);
}
$classes = array('project');
$work = get_custom_field($prefix . 'needs_work');
$classes[] = $work;
$output .= '<div class="' . implode(' ', $classes) . '">';
$output .= '<p><a href="' . get_edit_post_link() . '">' . be_get_project_name() . '</a><br />';
$output .= '<strong>Scheduled for: </strong>' . date('F j, Y', $start) . '<br />';
if ($status_summary) {
$output .= '<strong>Status:</strong> ' . $status_summary . '<br />';
}
if ($type) {
$output .= '<strong>Type:</strong> ' . $type . '<br />';
}
if ($revenue) {
$output .= '<strong>Budget</strong>: ' . $revenue;
}
if ($expense) {
$output .= ' - ' . $expense . ' = ' . $profit . '<br />';
}
//.........这里部分代码省略.........
示例10: the_custom_field
/**
* Echo Custom Field Value
*
* Same as get_custom_field except will echo out the value
*
* @since 1.1.8
*
* @param $field_slug Meta key from post
* @param null $job_id Optional, Post ID to get value from
* @param array $args
*
* @internal param null $output_as
* @internal param null $caption
* @internal param null $extra_classes
*/
function the_custom_field($field_slug, $job_id = null, $args = array())
{
$field_value = get_custom_field($field_slug, $job_id, $args);
if (isset($args['output_as']) && !empty($args['output_as'])) {
the_custom_field_output_as($field_slug, $job_id, $field_value, $args);
} else {
if (is_array($field_value)) {
$field_value = implode(', ', $field_value);
}
echo $field_value;
}
}
示例11:
<?php
}
?>
</div>
</div>
<!-- /CONTENT -->
<!-- ============================================== -->
<!-- SIDEBAR -->
<?php
if (get_custom_field('page_defaultpage_remove_sidebar') != 'Yes') {
?>
<div class="sidebar primary-sidebar <?php
echo $sidebar_class;
?>
">
<?php
dynamic_sidebar('default-widget-area');
?>
</div>
<?php
}
?>
<!-- /SIDEBAR -->
示例12: widget
function widget($args, $instance)
{
extract($args);
echo $before_widget;
echo $before_title . '10 Day Old Prospects' . $after_title;
$old = new WP_Query('category_name=prospect&showposts=-1&posts_per_page=-1&order=ASC');
$count = 0;
global $prefix;
if ($old->have_posts()) {
echo '<ol>';
while ($old->have_posts()) {
$old->the_post();
global $post;
if ($post->post_date > date('Y-m-d', strtotime('-10 days'))) {
continue;
}
?>
<li><a href="<?php
the_permalink();
?>
"><?php
the_title();
?>
</a>, <?php
the_date();
?>
<?php
edit_post_link('Edit', '(', ')');
?>
<?php
$status = get_custom_field($prefix . 'status_summary');
if ($status) {
echo '<br /><strong>Status:</strong> ' . $status;
}
?>
<br /><strong>Source:</strong> <?php
$sources = get_the_terms($post->ID, 'sources', '', ', ', '');
$list = '';
if ($sources) {
foreach ($sources as $data) {
$list .= $data->name . ', ';
}
echo $list;
}
echo '<br />';
$email = get_custom_field($prefix . 'client_email');
if ($email) {
echo '<strong>Email:</strong> ' . $email;
}
echo '<br />';
$phone = get_custom_field($prefix . 'client_phone');
if ($phone) {
echo '<strong>Phone:</strong> ' . $phone;
}
echo '<br />';
?>
</li>
<?php
$count++;
}
if ($count < 1) {
echo "<p>WooHoo! You're either really fast at responding to prospects, or you haven't set up your categories yet. </p><p>This area shows posts that are 10 days or older and in the 'Prospect' category. If you haven't done so already, create a category with the slug 'prospect'.</p>";
}
echo '</ol>';
} else {
echo "<p>WooHoo! You're either really fast at responding to prospects, or you haven't set up your categories yet. </p><p>This area shows posts that are 10 days or older and in the 'Prospect' category. If you haven't done so already, create a category with the slug 'prospect'.</p>";
}
wp_reset_query();
echo $after_widget;
}
示例13: test_get_custom_field
function test_get_custom_field()
{
CCTM::$post_id = 75;
$this->assertTrue(get_custom_field('rating') == 'R');
$this->assertTrue(get_custom_field('rating:raw') == 'R');
CCTM::$post_id = 77;
$this->assertTrue(get_custom_field('gallery:gallery') == '<div class="cctm_gallery" id="cctm_gallery_1"><img height="2592" width="1936" src="http://cctm:8888/wp-content/uploads/2012/06/2012-VACATION-059.jpg" title="2012 VACATION 059" alt="" class="cctm_image" id="cctm_image_1"/></div><div class="cctm_gallery" id="cctm_gallery_2"><img height="313" width="637" src="http://cctm:8888/wp-content/uploads/2012/08/I-just-had-sex.jpg" title="I just had sex" alt="" class="cctm_image" id="cctm_image_2"/></div>');
}
示例14: get_the_title
echo get_the_title();
?>
</p>
<p class="<?php
if ($i == 4) {
echo 'lremb';
} else {
echo 'lrem';
}
?>
" data-position="235,200" data-in="left" data-step="1" data-delay="1500" data-out="fade"><?php
echo get_the_content();
?>
</p>
<p class="teaser" data-position="325,200" data-in="left" data-step="1" data-delay="1500" data-out="fade"><a href="<?php
echo get_custom_field("slide_link");
?>
">Learn how we work</a></p>
</div>
<?php
}
?>
<?php
$i++;
}
$wp_query = null;
$wp_query = $temp;
// Reset
?>
</div>
示例15: crmpress_dashboard_widget
function crmpress_dashboard_widget()
{
global $post, $prefix;
echo '<h2 class="dash-title">' . get_bloginfo('name') . ' Project Information</h2>';
echo '<div class="active-projects">';
echo '<h2>Active Projects</h2>';
echo '<ul class="column-one">';
$active = new WP_Query('category_name=active-project&posts_per_page=20');
while ($active->have_posts()) {
$active->the_post();
$revenue = get_custom_field($prefix . 'revenue');
$expense = get_custom_field($prefix . 'expense');
$budget = $revenue - $expense;
$status = get_custom_field($prefix . 'status_summary');
$url = get_custom_field($prefix . 'client_url');
echo '<li>';
?>
<h3><a href="<?php
echo get_edit_post_link();
?>
"><?php
the_title();
?>
</a></h3>
Status: <?php
echo $status;
?>
<br />
Budget: <?php
if ($revenue) {
echo '$';
}
echo $revenue;
?>
- <?php
if ($expense) {
echo '$';
}
echo $expense;
?>
= $<?php
echo $budget;
?>
<br />
Website: <?php
if ($url) {
?>
<a href="<?php
echo $url;
?>
" target="_blank"><?php
the_title();
?>
</a><?php
}
?>
<?php
echo '</li>';
}
echo '</ul>';
wp_reset_query();
echo '</div>';
echo '<div class="scheduled-projects">';
echo '<h2>Scheduled Projects</h2>';
echo '<ul class="column-two">';
$schedule = new WP_Query('category_name=scheduled-project&posts_per_page=10');
while ($schedule->have_posts()) {
$schedule->the_post();
$revenue = get_custom_field($prefix . 'revenue');
$expense = get_custom_field($prefix . 'expense');
$budget = $revenue - $expense;
$status = get_custom_field($prefix . 'status_summary');
$action = get_custom_field($prefix . 'actionitem');
echo '<li>';
?>
<h3><a href="<?php
echo get_edit_post_link();
?>
"><?php
the_title();
?>
</a></h3>
Status: <?php
echo $status;
?>
<br />
Budget: <?php
if ($revenue) {
echo '$';
}
echo $revenue;
?>
- <?php
if ($expense) {
echo '$';
}
echo $expense;
?>
= <span style="color: #0CB636;">$<?php
echo $budget;
//.........这里部分代码省略.........