<font font face="cursive" color="DarkGoldenRod" font size="2";>
<?php
//your code here!
//Display posts where the custom field key is 'Relevance_Scale' and the custom field value is '9':
$args = array(
'meta_key' => 'Relevance_Scale',
'meta_value' => array ('7','8','10'),
// 'meta_compare' => '!=',
//'orderby' => 'meta_value',
);
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() )
{
while ( $query->have_posts() )
{
$query->the_post();
echo '<b><a href="' . get_permalink() . '">' .
get_the_title() . '</a> </b><br/>';
// To display Relevance Scale
$mykey_values = get_post_custom_values( 'Relevance_Scale' );
foreach ( $mykey_values as $key => $value )
{
echo " <b>Relevance Scale = " ."$value <br /> </b>";
// To display Relevance Scale
}
}
} else {
// no posts found
echo "No Posts";
}
/* Restore original Post Data */
wp_reset_postdata();
?>
</font>
]]>The Loop start with the typical:
<?php
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
So I read around and people in previous posts suggested to use this before:
<?php query_posts('meta_key=data&orderby=meta_key&order=DESC');?>
But doesn’t work.
The table fields where he’s grabbing data with mysql is something like this:
INSERT INTO
wp_postmeta(
meta_id,
post_id,
meta_key,
meta_value`) VALUES
(86074, 15099, ‘orario_corsi’, ‘15.00 – 18.00’),
(86075, 15099, ‘tipo_corso’, ‘Demo gratuita’),
(86076, 15099, ‘punti_vendita’, ‘a:1:{i:0;s:8:”Collegno”;}’),
(86077, 15099, ‘data’, ‘20130930’),
(86078, 15099, ‘prezzo_corso’, ”),
(86079, 15099, ‘_wp_page_template’, ‘default’),
(86080, 15099, ‘_yoast_wpseo_linkdex’, ’43’),
(86081, 15099, ‘_edit_lock’, ‘1378307873:1’),
(86082, 15099, ‘_thumbnail_id’, ‘14271’),
(86083, 15099, ‘_edit_last’, ‘1’),
(86084, 15099, ‘novità’, ‘0’),
(86085, 15099, ‘_novità’, ‘field_51a49e93b7613’),
(86086, 15099, ‘_punti_vendita’, ‘field_51891cfde30f4’),
(86087, 15099, ‘_data’, ‘field_518cbb149ef68’),
(86088, 15099, ‘_orario_corsi’, ‘field_521f68b550fbd’),
(86089, 15099, ‘_prezzo_corso’, ‘field_521f6a53c2ec6’),
(86090, 15099, ‘_tipo_corso’, ‘field_521f68fbb78a5’),
(86091, 15099, ‘gallery’, ‘0’),
(86092, 15099, ‘_gallery’, ‘field_517b9480b9e6d’),
(86093, 15099, ‘documenti’, ‘0’),
(86094, 15099, ‘_documenti’, ‘field_517b94ece23db’),
(86095, 15099, ‘_expiration-date’, ‘1380578400’),
(86096, 15099, ‘_expiration-date-options’, ‘a:2:{s:10:”expireType”;s:5:”draft”;s:2:”id”;i:15099;}’),
(86097, 15099, ‘_expiration-date-status’, ‘saved’),
(86098, 15099, ‘_yoast_wpseo_focuskw’, ‘medium materici’),
(86099, 15099, ‘_yoast_wpseo_title’, ‘Rilievi d”effetto – Viridea’),
(86100, 15099, ‘_yoast_wpseo_metadesc’, ‘Usiamo i medium materici per effetti tridimensionali.’),
(86101, 15099, ‘_yoast_wpseo_meta-robots-noindex’, ‘0’),
(86102, 15099, ‘_yoast_wpseo_meta-robots-nofollow’, ‘0’),
(86103, 15099, ‘_yoast_wpseo_meta-robots-adv’, ‘none’),
(86104, 15099, ‘_yoast_wpseo_sitemap-include’, ‘-‘),
(86105, 15099, ‘_yoast_wpseo_sitemap-prio’, ‘-‘),
(86106, 15099, ‘_yoast_wpseo_sitemap-html-include’, ‘-‘),
(86107, 15099, ‘_yoast_wpseo_canonical’, ”),
(86108, 15099, ‘_yoast_wpseo_redirect’, ”),
(86109, 15099, ‘_yoast_wpseo_opengraph-description’, ”),
(86110, 15099, ‘_yoast_wpseo_google-plus-description’, ”),
(86111, 15099, ‘_dp_original’, ‘14137’),`
Need help
Thanks!
]]>Fatal error: Call to a member function have_posts() on a non-object in
the code i had put is …
<?php if ($related_query->have_posts()):?>
<?php endwhile; ?>
<?php else: ?>
<p>No related posts.</p>
<?php endif; ?>
please any help
By default, it calls up posts in reverse chronological order. I just want to call pages instead of posts on the home page. Here’s the bit of code that I need to change, but don’t know how.
<?php /* Count the number of posts so we can insert a widgetized area */ $count = 1 ?>
<?php while ( have_posts() ) : the_post() ?>
<div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
<div class="entry-content">
<?php childtheme_post_header() ?>
<a href="<?php echo the_permalink() ?>"><span class="slide-title"><?php echo the_title(); ?></span>
<img class="thumbnail" src="<?php if(get_post_meta($post->ID, 'thumbnail', $single = true)){echo get_post_meta($post->ID, 'thumbnail', $single = true);} else{bloginfo('url'); echo "/wp-content/themes/gallery/images/thumbnail-default.jpg";} ?>" width="125" height="125" alt="<?php echo the_title() ?>" /></a>
</div>
</div><!-- .post -->
Sadly, I only know enough PHP to be dangerous and generally just dig into the codex for the solution to whatever minor problem I have. In this case, though, I just can’t figure it out. Any help would be appreciated!
Thanks,
Brian
On single.php I would like to display a second post from a different category that was posted on the same day. Here’s an example: The Original post was posted March 18, 2008. If a post from category “cake” was posted on March 18, 2008, display it:
Here is what I have so far:
<?php $dateOfOriginal = $post->post_date = date("Y m d",strtotime($post->post_date));
query_posts('cat=' . $cake); while(have_posts()) : the_post();
if ( $posts ) : foreach ( $posts as $post ) : start_wp();
$dateOfPostInCake = $post->post_date = date("Y m d",strtotime($post->post_date));
if($dateOfPostInCake == $dateOfOriginal) {
the_post();
} else {
_e('');
}
endforeach; else:
_e('');
endif;
endwhile; ?>
The first post_date query works fine, but the second one does not (it defaults back to “1969 12 31”). I’m assuming it has something to do with being inside of a nested loop. Any ideas on how to make it work? Thanks!
]]>On the pages for the single posts, I’m running into a small problem.
Basically, the page is set up like this:
HEADER (post title, excerpt, author, date)
SIDEBAR (below right of the header, with headlines from 3 other categories.)
BODY (text of the post)
The problem is, to get the sidebar headlines, I need to call the other categories. So when I call the_content, it places the wrong story content.
Is there any easy way to fix this? I don’t want to absolutely position the sidebar, because the header block can change in height.
Also note, this page appears to be rather broken in IE. I’ll be fixing that eventually—I’ve got until late August to finish this entirely. Also, this is my first WordPress theme ever (I’ve fiddled before, but nothing this serious) so the code is incredibly messy at times. I basically learned how to use CSS solely to create this. Bear with me.
https://arador.org/gazette/2007/05/11/haverfords-sharpless-and-our-sharples/ is an example, but it is happening for all of the stories.
If you have any other comments on the theme not related to this question, I’d love to hear them. Email me: mskorpe1 at swarthmore dot edu
]]>