Roger Theriault
Forum Replies Created
-
Forum: Plugins
In reply to: Reintegrate plugins into the core source codeStick the code in your functions.php file in your theme directory if you’d rather avoid the million plugin syndrome. Especially for simple stuff like the example posted. But be sure you understand the code… since you’ll have to maintain it after any core upgrades.
Forum: Plugins
In reply to: Weird comments behavior after using WP_query()When you’re done your “latest five posts” loop, try
<?php if (have_posts()) : while (have_posts()) : the_post(); update_post_caches($posts); ?> <!-- Do comment stuff here... --> <?php endwhile; endif; ?>
This is all documented on https://codex.www.ads-software.com/The_Loop#Multiple_Loops but you need to carefully read through all the examples to understand it, unfortunately.
Forum: Plugins
In reply to: Widgets- More than one instance of a plugin one a sidebarIt’s dependent on the widget code. In other words, it has to be designed into the widget. The standard WordPress text widget can have multiple instances, for example.
Forum: Plugins
In reply to: wp_enqueue_script – how do I use it?Too late when it gets to that stage. You’re better off adding the following to your theme’s functions.php file:
add_action( 'wp_print_scripts', 'xyztheme_add_javascript' ); function xyztheme_add_javascript( ) { wp_enqueue_script( 'jquery-ui-tabs', 'js/ui.tabs.js', array( 'jquery' ) ); }
This will force wp_print_scripts to include jquery as well as the tabs plugin before it outputs the rest of the headers. This seems to be the only action hook that works reliably with wp_enqueue_script.
And it makes a lot of sense to use it; my plugin loads the WordPress versions of these script files on 2.5.1, instead of the tab code I ship with the plugin… that helps avoid conflicts and duplicate code.
Forum: Plugins
In reply to: Custom sidebar content for each post page.I meant insert the code in the sidebar, wherever that is…
You need the numeric id (
$post->ID
) of the post, which is hidden behind the scenes by WordPress 2.5 unfortunately. However, when you edit that page using the editor, the page id will be in the URL (eg: 128 in this case):https://yourblog.com/wp-admin/page.php?action=edit&post=128
So you’d make the zone
sw-zone-id128
in the AdServe control panel.Forum: Plugins
In reply to: Loop won’t close so I can open another.Try this (replace query contents and “Do stuff” as appropriate):
<?php $my_query = new WP_Query('category_name=news'); while ($my_query->have_posts()) : $my_query->the_post(); ?> <!-- Do stuff... --> <?php endwhile; ?>
By storing the (new) query in a new instance, you should not be affecting the active query set up by WordPress.
You may need to add this function inside your main Loop, right after the_post():
update_post_caches($posts);
I noticed each time I look at the Loop documentation it has more and more examples. It’s great documentation; unfortunately it won’t cover every instance but if you read through it it will show you the best way to do things.
Forum: Plugins
In reply to: MySQL affected rowsThe return value of the query should give that number. The $wpdb class is in the wp-db.php file. Apparently some class attributes are created on the fly… try
$wpdb->rows_affected
(for insert/delete/update/replace)$wpdb->num_rows
(number of rows returned for select)$wpdb->insert_id
(id of last inserted/replaced record)$wpdb->last_error
$wpdb->print_error()
And you may find more gems in the code.
Forum: Plugins
In reply to: Showing 5 latest posts from one site in a different oneThat PHP function treats its argument as a local filesystem path, not a URI type path. Hence, you either need to add the directory where your files reside to the include path, or specify the exact directory, just like on Unix/Linux. You’ll find lots of comments on how those functions (ie
require()
,include()
, etc) operate on the php.net docs pages. For example, try “if (file_exists('foo.php'))
” (https://us3.php.net/manual/en/function.require.php). Again, this is all PHP stuff. If you know the directory (not URI) of the home page, and the relative location of your include file, then you can construct the path using PHP functions.But it doesn’t matter anymore… WP 2.6 will allow your wp_config.php and wp-content to reside pretty much anywhere, so you’ll need to know where to find it.
Forum: Plugins
In reply to: Can someone help me with my first widget please?There are a few fairly (in relative terms) simple widget examples in wp-includes/widgets.php. Usually you need to register a corresponding widget control (unless you want your widget to display the same heading all the time) and you need a few more arguments to the register_sidebar_widget function. I know there’s not a lot of documentation (that I can find) in the Codex, but your best bet would be to take a look at the code in that file… I was able to create a custom (multi-instance) widget by copying the text widget code and modifying it.
Oh and when you say “blank page”… typically the server doesn’t spit out totally blank pages. You may want to look at the page source to see if it contains PHP syntax error messages.
Forum: Fixing WordPress
In reply to: forgot admin pass in localhostForum: Developing with WordPress
In reply to: Custome permalink cause CGI error and server unavailableAre you using Apache? If so, is the rewrite module compiled in? Or if you’re using WAMP, make sure that module is checked.
If you create a blank .htaccess file, and then switch permalinks, WordPress should write the appropriate entries.
I have also update rewrite.php but it doesn’t work.
? What “update” ?
In your searching here, did you by any chance happen to see this page:
https://codex.www.ads-software.com/Using_PermalinksForum: Developing with WordPress
In reply to: wp_list_pages with add_link_attrRemoving the “;” was a good thing… that was the cause of your PHP error. You only need one at the end of a statement.
get_the_title() might produce some output.
But whatever you put in place of that function is going to turn out exactly the same in every line of the resulting list of links, unless there’s more to that plugin than first appears. I don’t think that’s going to do it for you. You might want to check out this page for some subquery examples that may allow you to accomplish what you need by constrcuting your own custom list: https://codex.www.ads-software.com/The_Loop
Or investigate a different plugin, there are thousands in the www.ads-software.com Plugin Directory
Forum: Plugins
In reply to: shortcodes for 2.3.3Won’t “upgrade” but wants selective bits of 2.5.1 ? The bugfixes and security fixes alone are worth the upgrade.
You might want to peek at some other plugin code, meaning plugins that implemented a shortcode system before 2.5 came out. But there are all kinds of methods, and now you’ll have one more thing to support.
Forum: Fixing WordPress
In reply to: flowing text around picturesYou’ll find CSS can do a lot, once you know most of the tricks.
The best thing you can do is use a class for your images, rather than an align attribute. (eg:
<img class="left-image" ... />
) And then in the css file, for your left aligned images, define them as:.left-image { float: left; clear: right; }
The “float” business in CSS can be a headache to do properly since it’s not very intuitive (or rather, what we typically get isn’t what we expect). But this (and the mirror for a right image) will get you further.
The WordPress image classes set by the editor can be (re)defined in your theme’s style.css file. (In some themes, they aren’t even defined)
Trying to figure out what all that is? Just Google “css float” or “css clear” and you should find some help.
Forum: Developing with WordPress
In reply to: wp_list_pages with add_link_attrWell it’s “onmouseover” to be strictly compliant with XHTML standards. No Caps!
And you should check the PHP docs for the difference between single and double quotes. There really is a big difference.
'onMouseover="expandcontent(\'' . $NOTHING . '\', this)"'
should work better.
And this doesn’t belong in Advanced… it’s not even a WordPress question.