Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

change wordpress site slug WordPress

  • REFUNDED

I need to adding something in my child functions.php to change slug from "campaigns" to something else. Right now it depends on

define( 'EDD_SLUG', apply_filters( 'atcf_edd_slug', 'campaigns' ) );

from a plugin. I can't edit that plugin (should be update often) and I should resolve it in child theme

Answers (6)

2014-02-11

Hariprasad Vijayan answers:

Hello,

Try this in your function.php

define( 'EDD_SLUG', 'new_slug' );

[[LINK href="https://easydigitaldownloads.com/docs/edd_slug/"]]Check this thread[[/LINK]]


tomaso1980 comments:

Hi Hariprasad, thanks, but it doesn't work


Hariprasad Vijayan comments:

Above thread mention something like
"Note: after doing this, you should resave your permalink structure for the changes to fully take effect."


Hariprasad Vijayan comments:

You are using easydigitaldownloads plugin right?


tomaso1980 comments:

Yes, with crowdfunding plugin, that contains

define( 'EDD_SLUG', apply_filters( 'atcf_edd_slug', 'campaigns' ) );

Also re-saving permalink won't change slug.


Hariprasad Vijayan comments:

Did you check this
https://easydigitaldownloads.com/docs/edd_slug/


tomaso1980 comments:

Yes. look the last comment of Maurizio. He had my same problem, he resolved it, but he didn't write how he managed to do it :)

2014-02-11

Luis Abarca answers:

It's a custom post type ?


// Original fila
define( 'EDD_SLUG', apply_filters( 'atcf_edd_slug', 'campaigns' ) );


// Your functions.php
add_filter('atcf_edd_slug', 'change_campaigns_slug');

function change_campaigns_slug($name)
{
return $name = 'something-else';
}


You can also rename custom post type slug of any plugin redeclaring the CPT.


// Your functions.php
function change_slug_of_post_type_x()
{
register_post_type('campaigns', array(
'rewrite' => array (
'slug' => 'somethin-else'
)
)
);

add_action('init', 'change_slug_of_post_type_x', 20);


tomaso1980 comments:

Yes, it's a custom post type. But first solution doesn't change slug and second solution breaks site.

2014-02-11

Balanean Corneliu answers:

I think you have here the solution for your problem.
http://stackoverflow.com/questions/4518527/customize-the-auto-generation-of-post-slug-in-wordpress


tomaso1980 comments:

Maybe, so what I should add to functions.php?


Balanean Corneliu comments:



To change custom post type slugs, follow the steps below;

1) Open your FTP or Cpanel and locate folder wp-content. Open it, then open folder “themes” and your theme folder.

2) Now you can open folder “includes” and locate “functions/custom-posty-types.php” file in there. You need to edit this file in any editor.

3) You can locate all post types and slugs in file “functions/custom-posty-types.php”. All the file content is split into logical block and it will be easy to navigate it. You can also use search feature and just search for slug you need to update.

4) Locate and replace post type slug with any slug you need, try not to use spaces.

The script should look like:

'rewrite' => array('slug' => 'portfolio', 'with_front' => true),


5) Save the file and test your website.

6) Sometimes you may get 404 error after changing custom post type slug, it is related to permalinks issue. You need to open admin panel, change permalinks structure to default, save website and then revert it to previous state.


tomaso1980 comments:

Mumble. I don't have functions/custom-posty-types.php in my theme. Also, I need to modify slug from child theme.


Balanean Corneliu comments:

What theme you use?


tomaso1980 comments:

Fundify


Balanean Corneliu comments:

The solution is here why you say maurizio dont tell how he solved?


maurizio
January 20, 2014 at 8:04 am

i found the problem! YAY!

in the plugin called appthemer-crowdfunding there is a file called crowdfunding.php
in there there is

// EDD Slug above all.
define( ‘EDD_SLUG’, apply_filters( ‘atcf_edd_slug’, ‘campaigns’ ) )

so now it is solved!
thanks!


Balanean Corneliu comments:

You need to leave this slug filters just in function.php if you have defineds twice it will not work properly.


tomaso1980 comments:

Because that is not the solution. Maurizio says he found the problem. The problem is that there is a plugin (Crowdfunding) that defines slug. As I wrote in the first post :)
He didn't say how he solved the problem


Balanean Corneliu comments:

He cut out that code from theare.

2014-02-11

Bob answers:

Notice that they are using filter so try something like this

Add following in your functions.php and change NEWSLUG with the slug you desire.

function my_new_slug_for_campaign( $slug ) {
return 'NEWSLUG';
}
add_filter( 'atcf_edd_slug', 'my_new_slug_for_campaign' );


Please note you might have to set paramalinks to default and revert it back to whatever is there.
or sometime you may have to event switch theme and revert back to original theme.


Bob comments:

functions.php means you child themes functions.php file.


Bob comments:

oops! you already tried above code. however try switching themes.


tomaso1980 comments:

doesn't work

2014-02-11

Sébastien | French WordpressDesigner answers:

In your plugin, the function download_names( $labels ) change the labels "downloads" into "campaigns"
/**
* Further change "Download" & "Downloads" to "Campaign" and "Campaigns"
*
* @since Astoundify Crowdfunding 0.1-alpha
*
* @param array $labels The preset labels
* @return array $labels The modified labels
*/
function download_names( $labels ) {
$cpt_labels = $this->download_labels( array() );

$labels = array(
'singular' => $cpt_labels[ 'singular_name' ],
'plural' => $cpt_labels[ 'name' ]
);

return $labels;
}


tomaso1980 comments:

doesn't work..


Sébastien | French WordpressDesigner comments:

it's not a solution. I pointed a function.


tomaso1980 comments:

please, help me find the solution..


Sébastien | French WordpressDesigner comments:

PS : I suppose that maurizio had simply change the code into the plugin into

//define( 'EDD_SLUG', apply_filters( 'atcf_edd_slug', 'campaigns' ) );
define( 'EDD_SLUG', apply_filters( 'atcf_edd_slug', 'my_new_slug' ) );


Sébastien | French WordpressDesigner comments:

to me, the solution is to modify the plugin...


tomaso1980 comments:

Yes, but then updating plugin will result in a broken site...


Sébastien | French WordpressDesigner comments:

you can change the line in your plugin into
if ( ! defined( 'EDD_SLUG' ) ) define( 'EDD_SLUG', apply_filters( 'atcf_edd_slug', 'campaigns' ) );
and add in wp-config
define( 'EDD_SLUG', 'my_slug' );


Sébastien | French WordpressDesigner comments:

<blockquote>Yes, but then updating plugin will result in a broken site...</blockquote>
so, use a rewrite url in htaccess or via the wp rewrite function


tomaso1980 comments:

Does this solution create problems with rss or seo?


Sébastien | French WordpressDesigner comments:

no.
which problem ?


tomaso1980 comments:

Ok, I'll try. Please post the two different solution:
- htaccess
- wp rewrite
Thanks!


Sébastien | French WordpressDesigner comments:

Redirect permanent /campaigns http://www.bookabook.it/new_slug

2014-02-13

Nile Flores answers:

Why not use the Custom Post Types UI plugin for WordPress for the custom post type - [[LINK href="http://wordpress.org/plugins/custom-post-type-ui/"]]Custom Post Type UI plugin[[/LINK]]. This helps you maintain any custom post types without adding to the functions.php and in the case of changing your theme in the future, you don't lose the CPT as it's saved in the plugin.

If you need to change any posts to that post type, you can briefly install Post Type Switcher - [[LINK href="http://wordpress.org/extend/post-type-switcher/"]]Post Type Switcher[[/LINK]]

Then do the htaccess rewrite.