muraii
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: [Plugin: Contact Form 7] Subpage appears upon submissionMy apologies. The issue was with a theme I was using, not the plugin.
Very nice work, again. Works like a charm on www.ads-software.com 2.7.1.
Daniel
Forum: Fixing WordPress
In reply to: Using SQL Query on Custom Post Meta Data to Restrict PostsHmm. So, it appears that I presumed complexity where there was none. I sent a note to Mr. Phu Ly, since he’d written up the piece on
query_posts
in the first place, asking for a little guidance. He very nicely and thoroughly explained that I had a good idea, but that there was a simpler approach that left The Loop intact. I felt immediately, well, retarded. But that’s another story.As well as category exclusion, what query_posts allows is the category inclusion. What you can do is the following: create 2 new categories called feature and nonfeature. This is akin to the values for the custom key that you had wanted to drive your post retrieval off.
Now for posts that you want to show in the featured column, link them to your categories as usual…but also link them to the feature category. Likewise, for posts in the non-featured column, link them as usual…but also link them to the category nonfeature.
Now, before the retrieval of entries in your feature block, call
query_posts(cat=[feature_category_id])
and before the retrieval of entries in your non-feature block callquery_posts(cat=[non_feature_category_id])
.This is basically what lellie was talking about, too.
So, like, while I think it’s a valid wishlist item to be able to run
query_posts()
with meta data as the input(s), Phu provided the solution to our dilemma here. This, like using meta data, also extends well: if you want to segregate the first column from the second column from the 3rd column, explictly, just make sure the have a separate category for each column and call that in thequery_posts()
function.Thanks Tomm for the theme, and Phu for the enlightenment.
Forum: Fixing WordPress
In reply to: Using SQL Query on Custom Post Meta Data to Restrict PostsOkay, I’ve made some progress; but there are still some pieces that won’t fit together. First, the good news.
The SQL query I had was okay, but needed some variables defined. I’d pored over the
functions.php
file and figured out the right syntax, and had taken the variable$new
to be a WordPress defined class like$wpdb
. It isn’t, so that needed to be defined. Here’s what I have:function featureColumns ($feature_stub) {
$feature_stub = "Feature";
$now = current_time('mysql', 1);
$featurePosts = $wpdb->get_results(
"SELECT DISTINCT *
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->postmeta.meta_value='$feature_stub'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_date <= '$now'
ORDER BY $wpdb->posts.post_date DESC
LIMIT 3");This creates the function
featureColumns
which gives you a query object$featurePosts
which holds all the stuff from thewp_posts
andwp_postmeta
tables for any published post not post-dated after right now and which has the ‘meta_value’ of “Feature”.The next step is to take this and, well, use it. So that you keep whatever formatting WP and any plugins provide, you need to wrap it in a filter function, too. So, in place of
<?php the_content() ?>
use
<?php echo apply_filters('the_content',$featurePost->post_content) ?>
Since we’re working around the limitations of the
query_posts
andget_posts
functions, well, we don’t get to make use of the built-in Loop. We have to create our own. I commented out the entire business of<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
and added a
foreach
loop, to end up with<?php // if (have_posts()) : while (have_posts()) : the_post();
foreach($featurePosts as $featurePost):<!-- Post-level HTML and other stuff here... -->
endforeach ?>
So, that works well enough, and will give you your own Loop; but there are definitely limitations:- The posts don’t currently reflect to what categories they belong.
- There is a SQL error with the comments for each of my test posts.
I’m sure there are others as well. I think that the primary reason for the issues is that the query object
$featurePosts
only includes content from thewp_posts
andwp_postmeta
tables. Obviously, then, yourindex.php
has no clue where to find stuff for your categories or comments.
I tried to include thewp_categories
,wp_post2cat
, andwp_comments
tables as well, so that the$featurePosts
object was “fully loaded”. That resulted in a page that wouldn’t load. I can only assume that that is a result of the sheer volume of data I’m trying to cram into that query object. I don’t know.I’m not much of a coder of anything–not XHTML, CSS, PHP, or SQL–so if there is someone about with some stronger aptitude who can tell me where I’ve gone wrong, I’d happily fix this. I want at least to release a PHP file for inclusion, but there would be room for a nice little control panel to set the meta data and control stuff better. I have no idea how to make a plugin or add a control panel, though.
Daniel
Forum: Fixing WordPress
In reply to: how to make the_content `<!–more–>` work on single pageOf course, if you had excerpts for your posts, you could replace
the_content()
withthe_excerpt()
. I’m not sure if you’re willing to go through the exhaustive measure of copying the text before your<!--more-->
and pasting that as your excerpt, but it would seem to work with a minimum of coding. Otherwise, it would seem that you’d need to figure out a way to override WordPress’s default designation ofis_page
to your page template, but that sounds like a mess.Forum: Fixing WordPress
In reply to: Using SQL Query on Custom Post Meta Data to Restrict PostsTomm,
I think the “it’s not earthshattering” might’ve come across a bit more acerbic than I intended. I wanted to preempt the “it’s not the ONE TRUE LAYOUT” replies. I think it’s very clean, and well considered.
I would like to find a way to
(a) extend its capabilities with some custom querying, if necessary; and
(b) possibly make that extension a plugin for others’ uses.There’s really not much to updating the looks except for maybe custom bullets or other little things. I like the simple approach, a la https://www.erraticwisdom.com, etc.
We’ll think of something!
Forum: Fixing WordPress
In reply to: Created home.php, but no effect is seenOkay, so I should’ve tested that part of the question first. I, in fact, do generate a root document of “blarg” when replacing all other stuff in home.php. So the issue, then, must be with my usage of the
query_posts()
code.Now that I look at it, though I’m using WP 1.5.2, the beginning of The Loop seems to use the older WP 1.2 syntax. Updating that fixed everything. Holy crap.
Danke sehr schön.
Daniel