Forum Replies Created
-
AuthorPosts
-
bmillerMember
Thank you -- will continue to work on this.
bmillerMemberReading Settings = Front Page Displays Your latest posts.
1. I have created a Post category called "meeting-event"; its category ID happens to be "4". Currently there are two other categories I set for Posts, but they are not important right now to what I need to do.
2. I have created a custom field called "date" and I am entering values for this custom field in the form "yyyy-mm-dd" . . I only add this custom field for Posts that have the category "meeting-event".
3. On the Front Page, I only want to display meetings and events which are scheduled in the future, hence my query logic of selecting all published Posts where category ID = '4' AND date > NOW()
4. I wrote a MySQL query to test my selection using phpMyAdmin and it worked like a charm.
5. I want to incorporate this custom query in a copy of the Genesis php file that creates the Front Page, but with my current understanding of Genesis and the Beautiful-Pro child theme, I don't know which php file to work with. I have attempted to rewrite the custom query in a WordPress format in lines 15 - 26 in the code snippet above. The rest of the code came right out of the Codex as an example in creating a custom template file.
6. I want the php file that builds the Front Page to work exactly as it does now except for the modified database selection query.Thank you for hanging in with me on this one.
bmillerMemberbmillerMemberOk, thanks, braddalton.
I hope this works as the code was copied from a web page (Codex) originally.
bmillerMemberOh boy. Followed the link to Github Gists and pasted the example Codex template page with my modified query into the open window. I created a public Gist, but besides that I have never used this tool and I'm not sure what you are requesting me to do.
I copied from the Gist window and have re-pasted here at the end of this post.
As to your request to shorten my question and clarify . . .
Question: I am looking for direction as how to create a custom template using a custom query using Beautiful-Pro so that the the front page (set to display "your latest posts") displays only posts of a designated category based on the value of a custom field.
Additional information: I have successfully tested a query using my database and PhpMyadmin that gives me the results I want, and I have attempted to translate the query using WP template tags and object style into an example template file I found in the Codex.
I am struggling here as I am a brand new WordPress user.
Thank you, and I appreciate your patience.
--bmiller
<?php
/*
Template Name: Qbased
*/
?><?php get_header(); ?>
<div id=”content” class=”narrowcolumn”>
<?php
$querystr = ”
SELECT $wpdb->posts.*
FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)WHERE $wpdb->term_taxonomy.term_id = ‘4’ AND
$wpdb->posts.post_status = ‘publish’ AND
$wpdb->posts.post_type = ‘post’ AND
$wpdb->postmeta.meta_key = ‘date’ AND
$wpdb->postmeta.meta_value > NOW()
ORDER BY $wpdb->postmeta.meta_value
“;$pageposts = $wpdb->get_results($querystr, OBJECT);
?>
<?php if ($pageposts): ?>
<?php global $post; ?>
<?php foreach ($pageposts as $post): ?>
<?php setup_postdata($post); ?><div class=”post” id=”post-<?php the_ID(); ?>”>
<h2>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”>
<?php the_title(); ?></h2>
<small><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></small>
<div class=”entry”>
<?php the_content(‘Read the rest of this entry »’); ?>
</div><p class=”postmetadata”>Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’, ”, ‘ | ‘); ?>
<?php comments_popup_link(‘No Comments »’, ’1 Comment »’, ‘% Comments »’); ?></p>
</div>
<?php endforeach; ?><?php else : ?>
<h2 class=”center”>Not Found</h2>
<p class=”center”>Sorry, but you are looking for something that isn’t here.</p>
<?php include (TEMPLATEPATH . “/searchform.php”); ?>
<?php endif; ?> -
AuthorPosts