Roger Theriault
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: add_action passing parametersUm, have you tried $_POST[‘new_field’] yet?
(Don’t forget to sanitize the user input before you run ANY query. See $wpdb->prepare here: https://codex.www.ads-software.com/WordPress_Coding_Standards.)
Forum: Fixing WordPress
In reply to: Custom Field Output – Code Help NeededDo a bit of basic debugging…
$postKey = get_post_custom_values('RotatingPostCover', $post->ID);
andecho "ID=[". $post->ID . "]"; var_dump($postKey);
will tell you what is stored there, what the ID was that you though you had, and why you’re getting nothing. Sometimes it’s caused by some other code that ran earlier, changing your $post. Or maybe the first instance of your custom field is blank.
Forum: Fixing WordPress
In reply to: Custom Field Output – Code Help Neededsrc=’Array’ means $postKey is an array.
https://codex.www.ads-software.com/Using_Custom_Fields
Sometimes the output is an array. If you want a list, use the foreach loop:
https://codex.www.ads-software.com/Function_Reference/get_post_custom_values
Or if you just want the first, use the older function:
$postKey = get_post_meta('RotatingPostCover', $post->ID, true);
https://codex.www.ads-software.com/Function_Reference/get_post_meta
Forum: Plugins
In reply to: Weird comments behavior after using WP_query()@marcomail, we’re talking about a posts query. comments.php is only supposed to display comments, not posts. Look in single.php. That page typically includes comments.php, so on a single post page, it uses the $wp_query->comments list to display the comments for the related post.
If you’re writing a custom query (like the posters above), then we’re explaining that you need to restore the default $wp_query global variable, otherwise your comments_template() function call will use the most recent query data, and display the wrong comments or none at all.
I hope that’s why you asked your question.
BTW there is a have_comments() loop, but for comments.php customization you should stick with the default comments.php and just use CSS, or make a custom Walker class if you like to dig into PHP.
Forum: Fixing WordPress
In reply to: add_action passing parameters@anoopu: I see you’ve made several posts (which is good, since this thread is not the right place for a new topic), none answered… (which suggests you need to provide more – a lot more – detail). You may want to try searching, or provide more detail in the thread you started under “Plugins and Hacks”.
Forum: Plugins
In reply to: Real Estate plugin releasedFor that suburbview.com (and similar sites), all it needs to do is read the syndication feeds (ie Trulia or Zillow) from a Great-Real-Estate enabled site. Both feeds are similar. (Google base is a bit different, but another option too).
Forum: Plugins
In reply to: passing results between filtersYou’ll need to trace back the order of execution; you’re right, it certainly does matter, at least in WordPress. (Sorry, there are enough “I pasted this stuff together why doesn’t it work” questions lately… seems nobody wants to go and read the PHP man pages)
For tracing the sequence of events, aside from the php files themselves, this resource might be helpful: https://adambrown.info/p/wp_hooks/version/2.7. There can be many reasons leading up to a particular action or filter being triggered… enough that I tend to favor the “go back and collect the data when it’s needed” method – even if it means an extra db query or two – instead of the “I just published a new post so let’s increment counter X” approach. Good luck.
Forum: Plugins
In reply to: passing results between filters@lakong – please don’t bump
Did you ever declare this variable outside of the scope of a function?
Sounds like a php issue. The answer here: https://us2.php.net/global
Forum: Plugins
In reply to: creating different sidebar filesForum: Plugins
In reply to: passing results between filtersAt some point that global needs to have something assigned TO it. Did you simplify that out?
Forum: Plugins
In reply to: Display only to certain Usernames?Shouldn’t be an issue, as long as your server is properly configured. Try loading archive.php directly using the path (ie /wp-content/themes/foo/archive.php) and then view source. You should either get an error, or not much of any use. Only someone with login access to your machine would see them.
If you want to make it more complex, and you know their user ids or logins, you could use that instead of user_email.
Forum: Plugins
In reply to: Filter categories on custom fields?Two tips for digging into WordPress core:
1) Google “wordpress functionname” and look for a phpxref site. Usually these cross-references will show which core file the function is in (then it’s a simple matter of opening the file up from your site) and all the calling files (to see how it’s used) and then a link to source code. (You seem to have already perused the get_categories() code)
2) When writing code, if it’s hard to work out what WordPress is giving you in a function return (because there are many levels of functions, etc) add
print_r($result);
to your code and look in your browser for a dump of the array or object.So try
$whoknows = get_categories(); print_r($whoknows);
to see what you get. Hopefully it’s useful.
Unfortunately the Taxonomy stuff is fairly complex.
Forum: Plugins
In reply to: Real Estate plugin released@modelcitizen – no search options yet. It’s more designed (in the current version) for listing agents to showcase a handful of listings.
Forum: Plugins
In reply to: Filter categories on custom fields?You should find some filter docs (and the actual source code) here:
https://adambrown.info/p/wp_hooks/version/2.7Forum: Plugins
In reply to: Display only to certain Usernames?https://codex.www.ads-software.com/Function_Reference/wp_get_current_user
then use (after you set up $current_user per the example)
<?php $message_users = array('[email protected]','[email protected]'); if (in_array($current_user->user_email, $message_users)) { ?> <h2>Hi Folks!</h2> ... etcetera <?php } ?>
Keep in mind that codex doc is incomplete, there are some defined functions that are easier to use in templates, such as
is_user_logged_in()
and if you’re going to use this a lot you might want to create a function such asis_user_email($email_list)
and put it in your theme’s functions.php file so your templates are cleaner.function is_user_email( $email_list ) { global $current_user; get_currentuserinfo(); if ( !is_array( $email_list ) ) { $email_list = array( $email_list ); } return in_array( $current_user->user_email, $email_list ); }
This function will also handle a single email, such as
if ( is_user_email('[email protected]') ) { ...
If you prefer, you can test against user_login instead of user_email.