guar
Forum Replies Created
-
There’s a beta version of this plugin which does this, or you can use the current version, plus a plugin I wrote which adds your CPTs. This you can get from my site@ http://www.getupandrunning.net/2010/06/adding-custom-content-types-to-the-sitemap/
Just download and activate it.
@solutionsphp you don’t need to copy anything into the functions.php – the code example on my site is if you want to further modify my plugin. Just download my plugin zip, activate it and you’re ready to go. (You may need to refresh the sitemap from the admin panel).
MarkForum: Hacks
In reply to: How to create automatic posts on registration?You don’t need to edit wp-register.php (you can do almost anything with WP without editing core files), but you do need to be familiar with filters and actions.
Basicially, you want to add your own action after WP has registered your user, and then you can add posts using
wp_insert_post(http://codex.wordpress.org/Function_Reference/wp_insert_post).I think the action you need to hook into is
user_registerorprofile update. Unfortunately, there isn’t much in the way of documentation for these hooks.So your code might look something like this:
add_action('user_register', 'my_user_register'); function my_user_register($user_id) { $my_post = array( 'post_title' => 'My post', 'post_content' => 'This is my post.', 'post_status' => 'publish', 'post_author' => $user_id ); wp_insert_post($mypost); }Forum: Fixing WordPress
In reply to: upgrade wordpress from 2.8.3 to 3.0.1Such a large jump between WP versions is likely to bring up compatibility issues in plugins, which in turn may cause a white screen for each page on your site. So, de-activating plugins before upgrade is really important.
If you forget to do it before upgrading, all’s not lost, you can either clear the active_plugins field in the options table using phpmyadmin or rename the plugins folder so that the plugins aren’t loaded (WP will then deactive them because it can’t find them).
Forum: Plugins
In reply to: Different Posts number in CategoryYou’d have to get to grips with building a custom
WP_Query(). You may find the various filters useful, particularly,add_filter('posts_limits','my_post_limit_filter');which you can use to dynamically set your query limit.As for your links, or drop down, you’d need some custom query parameter, perhaps
?ppp=10which you can tack onto the page url.And then finally use some conditional functions such as
is_archive()to test when to modify the page limits.Hope that gives you some pointers.
Forum: Hacks
In reply to: submenu item for Custom Post TypeI feel like a complete dork – or perhaps the double espresso helped. The problem wasn’t with my add_submenu_page command, but with the add_action:
i.e. I had:
add_action("admin_init",array(&$this,'admin_menu'));instead of :
add_action("admin_menu",array(&$this,'admin_menu'));Makes all the difference you know.
Forum: Hacks
In reply to: Database query with AjaxHi Pete, the codex page you linked also links to this: http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/
Although it is counter-intuitive, you do need to be sending your requests from the javascript to the admin-ajax.php file. The hooks you define will be called from there, and from there your functions will be called.
Example Hooks:
// this hook is fired if the current viewer is not logged in add_action( 'wp_ajax_nopriv_myajax-submit', 'myajax_submit' ); add_action( 'wp_ajax_myajax-submit', 'myajax_submit' );The hook/action name is determined by the action field in the ajax request. So if your action is called “myajax-submit” you’d use the two actions above. The second argument is the name of the function to call in your plugin.
Forum: Hacks
In reply to: Passing Arguments to add_action?That will certainly create a lot of data, perhaps the more useful of which is to know the order the actions are executed. Good luck with that.
Forum: Hacks
In reply to: Passing Arguments to add_action?If you’ve just put in that code into your functions.php file then yes, it will run with every page load.
The do_action function normally resides inside other functions where and when you want something particular to happen.
Perhaps you want to link into WordPress’ default hooks (you’ll find a nice list here: http://adambrown.info/p/wp_hooks/hook/actions) such as post_updated. All you need do then is use add_action(‘post_updated’,’my_function’) to do whatever funky stuff you want to do.
Forum: Hacks
In reply to: Passing Arguments to add_action?That wouldn’t work because you’re adding the action after the do_action call. You should have something like:
$hook_array = array('publish_page','trash_page'); foreach($hook_array as $hook) { add_action($hook, 'my_function', 10, 1); do_action($hook, $hook); } function my_function($arg) { echo $arg; }It doesn’t do very much though, other than printing the name of the hook.
I’m not sure that this will do anything particular useful anyway, because presumably you want the actions to do different things and will have different numbers of variables, which will vary according to the context.
Forum: Hacks
In reply to: Passing Arguments to add_action?The arguments are defined by the do_action function as in the example here: http://codex.wordpress.org/Function_Reference/do_action
So somewhere you’d need:
do_action('publish_page',$arg1,$arg2);And your function should look something like:
function my_function($arg1,$arg2) { // do something with the args }And your add_action should be something like:
add_action($hook,'my_function',10,2);Where the “2” is the number of arguments.
I created an interim fix which you can download from my site: http://www.getupandrunning.net/2010/06/adding-custom-content-types-to-the-sitemap/
Arne’s working on a comprehensive update of the plugin so if you’re just after custom content types this will sort you out.
If you’re testing the new official release from @arnee and had installed my custom post type fix, you had better deactivate mine or else the universe may go spiralling out of control.
The plugin doesn’t currently include custom post types, I created a plugin to plugin this plugin. Just download my plugin and activate it. It works alongside Google XML sitemaps, not instead of.
Download: http://www.getupandrunning.net/2010/06/adding-custom-content-types-to-the-sitemap/
This forum topic discusses this issue: http://wordpress.org/support/topic/plugin-google-xml-sitemaps-support-for-custom-post-typs
@chocks It’s not set up to do that. The settings page only lets you set certain types of posts.
In other news: I’ve updated my plugin plugin to honour excluded PostIDs and Categories for Custom Content Types. You can get the update from my site at: http://www.getupandrunning.net/2010/06/adding-custom-content-types-to-the-sitemap/