MathSmath
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: How To: First and Last CSS Classes for Sidebar WidgetsAlso, as @rarst pointed out on the WordPress Stack Exchange board, the section that checks for an empty sidebar isn’t necessary…the filter only runs pre-widget output.
Forum: Fixing WordPress
In reply to: How To: First and Last CSS Classes for Sidebar WidgetsGood call, durin!
Forum: Themes and Templates
In reply to: Getting loop inside an iframeThe problem is that the files you’re trying to load (yourtheme/index.php, for example) can’t be loaded directly. In general (with some rare exceptions like the login page), WordPress doesn’t work by directly accessing files like that–those are TEMPLATE files that should only be accessed by WordPress itself. Know what I mean?
If you want to create a single php file that makes available WordPress functions (like queries and a loop), you have to do what’s called “bootstrapping” WordPress–loading up the WordPress framework that does all that website-generating magic–then manually creating a query for your loop to use.
Try putting the following code into a file, then save it as “news.php” in the root of your WP install (alongside wp-login.php, wp-config.php etc.).
<? // Bootstrap WordPress. This makes most WP functions availabe to you now. require( 'wp-load.php' ); // Your php file is out on its own here, so you need to manually create a query. You can find more about queries and the arguments they accept here: https://codex.www.ads-software.com/Function_Reference/query_posts $args = array( 'post_type' => 'post' ); query_posts($args); // Begin the loop, just like you normally would. while ( have_posts() ) : the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'mastercard' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <div> <?php the_excerpt(); ?> </div> <? endwhile; // end of loop ?>
Now you can call this file directly (yoursite.com/news.php), and it’ll load up a basic loop.
Hope this helps.
Forum: Fixing WordPress
In reply to: wp_nav_menu not working on homepageI just spent hours on the same symptom.
Try disabling all plugins, and look through your functions.php file to see if you have some code that modifies queries.
Don’t know if your underlying issue will be the same, but here’s what the problem was for me:
I had code in my functions.php file that was meant to include custom content types in search results, feeds, etc. (this kind of code could also exist in a plugin you’re using, which is why I suggested turning them off). My code looked like this:
function include_post_types($query) { global $wp_query; if ( !is_preview() && !is_singular() && !is_admin() ) { $post_types = array('post', 'press-releases'); $existing_post_type = get_query_var( 'post_type' ); // Only do this if the post type is not already set if ( empty( $existing_post_type ) ) { $query->set( 'post_type' , $post_types ); } } return $query; } add_filter('pre_get_posts' , 'include_post_types');
Pretty sure I found this code (or something similar) on the forum somewhere, so it’s possible other people are using it. The problem is, it assumes the global wp_query and the query being parsed by pre_get_posts are the same. But in custom queries using the WP_Query object (which the navigation widget and template tag uses), they’re not necessarily the same, and you might accidentally overwrite valid query vars.
I fixed it by doing something I should have done in the first place–removing the reference to the global $wp_query.
function include_post_types( $query ) { if ( !is_preview() && !is_singular() && !is_admin() ) { $post_types = array('post', 'press-releases'); $existing_post_type = $query->query_vars['post_type']; // Only do this if the post type is not already set if ( empty( $existing_post_type ) ) { $query->set( 'post_type' , $post_types ); } } return $query; } add_filter('pre_get_posts' , 'include_post_types');
Hope this helps!
Forum: Fixing WordPress
In reply to: Alternative page on first site visitI would advise against doing this. Depending on how it’s implemented, some search engines could see this as “cloaking” and penalize or delist you.
It’s also kind of annoying for someone who’s visiting your site. If a user clicks on a link promising “tasty cookie recipes” (or whatever your site is about) and they get your “about” page instead, they’re probably going to bail.
A better idea from a technical and user experience standpoint is something like WP Greet Box. Instead of taking you to a separate “splash” page and making you dig for the content, it displays your welcome messages inline with the content the user was expecting. Everybody wins!
Forum: Fixing WordPress
In reply to: Changed URL – wrecked everything :(Glad to see you got it working!
Forum: Fixing WordPress
In reply to: Changed URL – wrecked everything :(Sorry to keep firing posts out at you, but you know what I think might have happened? You may have changed the URL in the wrong database.
If you have two WP installs (which it looks like you do), there should be two DBs (unless you’re using WordPress MU, which is totally not a police code). Maybe you “fixed” the url in the wrong one?
When you go into your ipage control panel (or phpmyadmin…however they’re letting you manage the DB), do you see two databases listed, or just one?
I’m about to log off, but if you’re still struggling with this tomorrow morning, I’ll check back and see if I can come up with any more suggestions.
Forum: Fixing WordPress
In reply to: Changed URL – wrecked everything :(Oh, hey–if you haven’t already, try this fix mentioned in the “Changing the site URL” codex article:
Add these two lines to your wp-config.php, where “example.com” is the NEW location of your site.
define('WP_HOME','https://example.com'); define('WP_SITEURL','https://example.com');
This is not necessarily the best fix, it’s just hardcoding the values into the site itself. You won’t be able to edit them on the General settings page anymore when using this method.
Forum: Fixing WordPress
In reply to: Changed URL – wrecked everything :(Ah, okay. Try ADDING the www.
Which URL is supposed to go to which blog?
Forum: Fixing WordPress
In reply to: The date – template hacks?On Matt’s site, those dateless posts are set up as “asides”. Check out this codex article about setting up asides on your blog.
In WP3, you’ll also be able to do this easily using custom post types–you can set up an unlimited amount of different posts types and have each display differently.
Forum: Fixing WordPress
In reply to: Changed URL – wrecked everything :(Try changing it again, but removing the “www”.
Not sure how your domains are configured, but something weird is going on–if you go to https://vanessa-paris.com/ (minus the www), you get one blog. If you go to https://vanessa-paris.com/blog, you get redirected to a completely different blog at https://vanessaparisphotography.com/blog.
Do you have two WordPress installations running on the same box? Or some kind of domain forwarding set up?
Forum: Fixing WordPress
In reply to: Comment Notifications Not WorkingSome more basic things to check:
1) Disable ALL your plugins and try it. (You probably already did this, but lots of people don’t!)
2) Make sure the notifications are not going to your client’s spam folder.
3) Make sure there is nothing in your theme’s functions.php file that redefines the wp_mail() function or the wp_notify_postauthor() function (both of which are pluggable).I’ve had a problem recently where some emails don’t even make it to the spam folder, depending on the email provider/client. Turns out some providers automatically reject emails that don’t meet certain requirements, and sorting this out has been a tricky business.
Keep me in the loop!
Forum: Fixing WordPress
In reply to: Deleted wp-config > Lost the Keys > ??Good news–it doesn’t matter. Just fill those values in with new, random keys and everything should be good.
I think these keys are only used to salt encrypted values stored in your login cookies, so the worst case is that any users who were logged in before you updated your site will have to log in again.
Forum: Fixing WordPress
In reply to: Printing a postYou can specify a separate stylesheet for print, and use it to hide any elements you don’t want to, um, print. The basic trick is this: in addition to your regular stylesheet, link a print-specific stylesheet like so
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
There is a great primer on print stylesheets over at A List Apart.
EDIT: This stylesheet will kick in whenever the print function is triggered–whether by window.print, or by a user selecting file->print.
Forum: Fixing WordPress
In reply to: How to rename function by plugin?No, there is no WordPress filter that will rename php functions. The only functions that you can modify via plugins are the pluggable functions (and even those you can’t rename–that’s kinda what makes them pluggable).
If you explain exactly what you’re trying to do and why, we might be able to come up with an acceptable solution. My best guess is that you’re trying to declare your own function called make_clickable(), and you’re getting an error because it’s already defined. In which case, you can just use a different name for your function and problem solved.
If for some strange reason you need to call the make_clickable() function but want to call it using a different name, you can just wrap it in your own function:
function my_function_name($ret) { return make_clickable($ret); // Call the real fucntion, return the results }
If neither of those help, you’ll have to provide more info.