Wordpress: How to Disable Pinging for a Specific Category

I'd like detailed instructions on how to disable pinging for posts that are published in a given category. But I want all the posts in other categories to be ping'd when they are published.

Is there a setting in Wordpress that does this (I don't think so), or do I have to go into the "Loop" in my theme? Or is it in the "Core" code. In either case, please provide file names and code samples. Thanks.

Wordpress 2.9.2
Jerry LAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KysolCommented:
Just did a hunt around, looking for the hook, found an example to do something else and modified it to do what you needed.... but it hasn't been tested, so it mightn't work. But that hook should be what you are looking for.
<?php
   function ping_stop( &&$links )
   {
      $category = 'test';

      foreach ( $links as $link_id => $link_data )
      {
         if ( strstr( $link_data, '/category/' . $category . '/' ) )
         {
            unset( $links[ $link_id ] );
         }
      }
   }

   add_action( 'pre_ping', 'ping_stop' );
?>

Open in new window

0
KysolCommented:
My bad, that doesn't do it. I'll add code to it later when I get home. The hook is right, the function is not.
0
Jerry LAuthor Commented:
Thanks for helping out.

It may be relevant that I'm using a plugin that removes the /category/ slug entirely.
Can you also be more specific what file you are working with?

"WP No Category Base"
http://www.WordpressSupplies.com/wordpress-plugins/no-category-base.

0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

KysolCommented:
Yeah the issue with the code I first put there was that I for some reason was looping through the links thinking they were the category links when they are the links to get pimged. What has to be done is to grab the categories by I'd and if the Id of a category you want stopped is in the cat list, unset links array. That will pass no links through to wp and in turn stop them from being pinged.
0
KysolCommented:
Try this. It seems to be working here.
<?php
	function ping_stopper_post()
	{
		global $post_ID;

		$post_categories = wp_get_post_categories( $post_ID );

		if ( !in_array( '3', $post_categories ) )
		{
			do_action( 'generic_ping' );
		}	
	}
	function ping_stopper_pre()
	{
		remove_action( 'publish_post', 'generic_ping' );
		add_action( 'publish_post', 'ping_stopper_post' );
	}

	add_action( 'pre_post_update', 'ping_stopper_pre' );
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KysolCommented:
Forgot to say that "3" was my test category id.
0
Jerry LAuthor Commented:
Can you tell me where to put that code and from where & how to call the functions?
0
KysolCommented:
Make it a new plugin save it as say "ping-stop/ping-stop.php" in your plugin folder, then enable it.
0
Jerry LAuthor Commented:
I copied the code as-is, saved it and uploaded as you suggested. However, it is not showing up in the list of plugins on the Wordpress Admin > Plugins > Manage Plugins page.

I am not familiar with creating a plugin, so please provide complete instructions.  Thank you.
0
Jerry LAuthor Commented:
Submitted by osiris00:

How To Create A Plugin for Wordpress:

The directory / file name structure that you have is fine. You just need to place it under the wp-content/plugins/ directory on your server.

The top of your Plugin's main PHP file must contain a standard Plugin information header. This header lets WordPress recognize that your Plugin exists, add it to the Plugin management screen so it can be activated, load it, and run its functions; without the header, your Plugin will never be activated and will never run. Here is the header format:

<?php
/*
Plugin Name:     Name Of The Plugin
Plugin URI:         http://URI_Of_Page_Describing_Plugin_and_Updates
Description:       A brief description of the Plugin.
Version:             The Plugin's Version Number, e.g.: 1.0
Author:                Name Of The Plugin Author
Author URI:        http://URI_Of_The_Plugin_Author
License:             GPL
*/
?>

The minimum information WordPress needs to recognize your Plugin is the "Plugin Name" line. The rest of the information (if present) will be used to create the table of Plugins on the Plugin management screen. The order of the lines is not important.

Your plugiin uses a wordpress action hook  "add_action ".  At various times while WordPress is running, WordPress checks to see if  any Plugins have registered functions to run , and if so,  the functions are run.
0
Jerry LAuthor Commented:
I need to determine if this plugin is working. I've posted another question about that here:
http://www.experts-exchange.com/Web_Development/Blogs/WordPress/Q_26021549.html
0
Jerry LAuthor Commented:
Using the log files of both Smart Update Pinger and MaxBlogPress Ping Optimizer, they both indicate that the plugin ping-stop is not working. The pings were still processed. I've checked the category number, and it turns out to be "3" also, so no change needed. How do you suggest I might debug this?
0
Jerry LAuthor Commented:
The plugin did not seem to be working. When I requested more information, I never received a reply.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.