Wordpress 就我的技能水平而言,ooks非常复杂。你能给我举个例子,说明在我的情况下这是如何工作的吗?虽然这是可行的,但似乎没有必要检索所有的行并搜索它们……我完全同意你的看法。我的团队最终失去了这个项目(公司之间的一些愚蠢的政治),但是我很想知道你是否有另一个工作解
Wordpress 就我的技能水平而言,ooks非常复杂。你能给我举个例子,说明在我的情况下这是如何工作的吗?虽然这是可行的,但似乎没有必要检索所有的行并搜索它们……我完全同意你的看法。我的团队最终失去了这个项目(公司之间的一些愚蠢的政治),但是我很想知道你是否有另一个工作解,wordpress,custom-post-type,advanced-custom-fields,Wordpress,Custom Post Type,Advanced Custom Fields,就我的技能水平而言,ooks非常复杂。你能给我举个例子,说明在我的情况下这是如何工作的吗?虽然这是可行的,但似乎没有必要检索所有的行并搜索它们……我完全同意你的看法。我的团队最终失去了这个项目(公司之间的一些愚蠢的政治),但是我很想知道你是否有另一个工作解决方案来代替这个…?一种方法是直接访问SQL,我通常不鼓励这样做。。。但这在未来应该是稳定的:)看到我的答案了吗 <?php $args = array( 'post_type' => 'messages', '
就我的技能水平而言,ooks非常复杂。你能给我举个例子,说明在我的情况下这是如何工作的吗?虽然这是可行的,但似乎没有必要检索所有的行并搜索它们……我完全同意你的看法。我的团队最终失去了这个项目(公司之间的一些愚蠢的政治),但是我很想知道你是否有另一个工作解决方案来代替这个…?一种方法是直接访问SQL,我通常不鼓励这样做。。。但这在未来应该是稳定的:)看到我的答案了吗
<?php
$args = array(
'post_type' => 'messages',
'posts_per_page' => 1
);
$latestMessageQuery = new WP_Query($args);
if( $latestMessageQuery->have_posts() ) { ?>
<?php while ($latestMessageQuery->have_posts()) : $latestMessageQuery->the_post(); ?>
<?php if( have_rows('campus_message') ): ?>
<?php while( have_rows('campus_message') ): the_row(); ?>
<?php if( get_sub_field('campus_selector') == 'troy' ): ?>
<?php the_sub_field('message_speaker'); ?>
<?php else: ?>
<?php the_sub_field('message_speaker'); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php }
wp_reset_query();
?>
<?php
$args = array(
'post_type' => 'messages',
'posts_per_page' => 1
);
$current_campus_id = get_the_ID();
$latestMessageQuery = new WP_Query($args);
if( $latestMessageQuery->have_posts() ) {
while ($latestMessageQuery->have_posts()) : $latestMessageQuery->the_post();
if( have_rows('campus_message') ):
while( have_rows('campus_message') ): the_row();
if( get_sub_field('campus_selector') == $current_campus_id ):
the_sub_field('message_speaker');
the_sub_field('message_url');
break;
endif;
endwhile;
endif;
endwhile;
}
wp_reset_query();
?>
$query =
"SELECT option_name, option_value FROM {$GLOBALS['wpdb']->prefix}options"
." WHERE option_name LIKE ("
." SELECT"
." CONCAT( 'options\_your\_option\_name\_', CAST( REPLACE(option_name, 'options_your_option_name_', '' ) AS INTEGER ), '%' )"
." FROM {$GLOBALS['wpdb']->prefix}options"
." WHERE"
." (option_name LIKE 'options\_your\_option\_name\_%\_subfield\_name')"
." AND"
." (option_value = 'some subfield value')"
." LIMIT 0,1"
." )"
;
$results = $GLOBALS['wpdb']->get_results( $query, ARRAY_A );
if( !empty($results) ){
foreach($results as $result){
//do something with it :)
echo $result['option_name'] . " => " . $result['option_value'];
echo "<br>";
}
}
while (have_rows('repeater_name')) {
the_row();
if (get_sub_field('sub_field') != $unique_key) {
// not our row
continue;
}
// will get here if this is our row
$sub_field1= get_sub_field('sub_field1');
$sub_field2= get_sub_field('sub_field2');
}