jeffreyhmartin
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Second Loop in Sidebar of Twenty Ten Child ThemeThat did it! Getting this piece of code working has been the last holdup to going live with the update to my child theme.
There are several places on the web that explain how to run multiple loops on a page and prevent duplicate posts, but none of them worked without storing this as a global variable.
Many Thanks!
I’m going to wait to mark this thread as resolved temporarily just to be sure everything is good.Forum: Fixing WordPress
In reply to: Second Loop in Sidebar of Twenty Ten Child ThemeThe sidebar in Twenty Ten is called after the main loop.
I’m still fairly new to WordPress and php. How and where would I declare $do_not_duplicate as global before the main loop?
Does it involve a change to this code just before the main loop?
<?php $do_not_duplicate = array(); while (have_posts()) : the_post(); $do_not_duplicate[] = get_the_ID(); ?>
Thanks.
Forum: Fixing WordPress
In reply to: Second Loop in Sidebar of Twenty Ten Child ThemeI changed the variable $ids to $do_not_duplicate everywhere it was in the code, and added the suggested code to the sidebar.php as follows:
<!-- print out the Post ID, category, and what's stored in the variable $do_not_duplicate --> <?php global $do_not_duplicate; ?> <p>Result of print_r($do_not_duplicate): <?php print_r($do_not_duplicate) ?></p> <?php // Create a new instance $third_query = new WP_Query(array('post__not_in' => $do_not_duplicate)); // The Loop while( $third_query->have_posts() ) : $third_query->the_post(); ?> <?php echo '<li>'; the_title(); echo '</li>'; endwhile; wp_reset_query(); ?>
I’m still getting the same output – when the first loop runs on a category page, the output of print_r($do_not_duplicate) is: Array ( [0] => 353 [1] => 321 [2] => 194 [3] => 202 [4] => 112 [5] => 12 [6] => 10 ). But the output of print_r($do_not_duplicate) in the sidebar, just after
<?php global $do_not_duplicate; ?>
is still empty. Do I need to change anything about how the $do_not_duplicate variable is stored in the original array?Forum: Plugins
In reply to: "Google Analytics for WordPress" re-authenticateI had a similar problem of being repeatedly unable to authenticate with Google. In my Google account, I added my domain to the “websites authorized to access your account.” It still didn’t work, nor did any other Google Analytics plugins, which indicated I was missing something obvious here.
As a first-time user of Google Analytics, I did not realize that I had to create an account at Google Analytics. Once I did that, listed my domain there, got my UA code, and manually entered it in Google Analytics for WordPress, I was good to go. Note that when you’re in Google Analytics, you don’t need to copy and paste the code it gives you into the head of your webpage (your wordpress header.php), because the plugin does that for you.
If you’re having trouble authenticating, maybe some of you are having this same problem. Sometimes the simplest things are the ones you can’t find any support for, because everyone thinks you already know them (try searching online for a recipe for making simple oatmeal if you forgot the water/oats ratio).Forum: Alpha/Beta/RC
In reply to: How to Add Post Thumbnail in WP 2.9 Beta 1I read several explanations for how to get the Post Thumbnail function to show up in my Post Editor (WordPress version 3.0.1), and none of them worked until I created a functions.php file in my theme with the following code, as recommended by Matt Brett at https://mattbrett.com/workshop/2010/wordpress-post-thumbnails-revisited/
<?php
if (function_exists(‘add_theme_support’)) {
add_theme_support(‘post-thumbnails’);
}
?>Thanks to Matt.