Need help allowing user to "rewrite" the slug of a custom post with Option Tree without getting an error

210 posts
  • Located in Canada
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
+5 more
DanyDuchaine says

Hey guys,

So here is my problem, I have a custom post and I want to allow the user to specify the slug of the custom post as well as the taxonomy from the Option Tree dashboard so here is what I did : http://snippi.com/s/l59xl31

Unfortunately, it give me this error :

WARNING: wp-includes/functions.php:928 – Cannot modify header information – headers already sent by (output started at /Users/kailoon/Sites/wp35/wp-content/themes/MissionWP/includes/cpt-causes.php:4)

I’m pretty sure it’s simple but I can’t find how to fix this.

Can someone help?

Thanks!

332 posts
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 1+ items on Envato Market
+2 more
dekciw says

1. uft-8 without BOM

2. no blank lines before <?php

3. remove all unnecessary white space below the code

4. do not use ?> at the end of code

EDIT: Just checked my CPT snippet, it looks EXACTLY the same. :D Even this line:
            'description' => 'Easily lets you create some beautiful portfolios.',
:D
210 posts
  • Located in Canada
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
+5 more
DanyDuchaine says

1. uft-8 without BOM

2. no blank lines before <?php

3. remove all unnecessary white space below the code

4. do not use ?> at the end of code

EDIT: Just checked my CPT snippet, it looks EXACTLY the same. :D Even this line:
            'description' => 'Easily lets you create some beautiful portfolios.',
:D

OMG where have you find it? Mine come from my friend : OTOTW

:)

332 posts
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 1+ items on Envato Market
+2 more
dekciw says

Actually, don’t think that I’m accusing you of code stealing or something like that – I do not actually care if someone uses my snippets, etc. I’ve just said it as a fun fact :D You can check my cpt-portfolio.php here -> http://snippi.com/s/g9fwjch – and it works OK. So you’d better check for the stuff I’ve mentioned in my previous post.

Btw, I remember typing those descriptions myself. And never bought any OTOTW items :D

63 posts
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
PrimeThemes says

I suggest use apply_filters for dynamic variable like this,

line 29
'rewrite' => array( 'slug' => apply_filters('custom_causes_post', 'causes') ),
line 58
'rewrite' => array( 'slug' =>apply_filters('custom_causes_tax', 'item-type') )
and in your functions.php,
add_filter('custom_causes_post', 'danny_causes_custom_slug');
function danny_causes_custom_slug(){
     global $options;

     $url_rewrite = $options['theme_causes_item_url'];
     $slug = ( !$url_rewrite ) ? 'causes' : $url_rewrite;

     return $slug;
}

add_filter('custom_causes_tax', 'danny_causes_custom_tax_slug');
function danny_causes_custom_tax_slug(){
     global $options;

     $url_rewrite = $options['theme_causes_item_type_url'];
     $slug = ( !$url_rewrite ) ? 'causes' : $url_rewrite;

     return $slug;
}
210 posts
  • Located in Canada
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
+5 more
DanyDuchaine says

Actually, don’t think that I’m accusing you of code stealing or something like that – I do not actually care if someone uses my snippets, etc. I’ve just said it as a fun fact :D You can check my cpt-portfolio.php here -> http://snippi.com/s/g9fwjch – and it works OK. So you’d better check for the stuff I’ve mentioned in my previous post. Btw, I remember typing those descriptions myself. And never bought any OTOTW items :D

Doesn’t it come from Option Tree v2? :)

@PrimeThemes : Thanks! Will try this :)

741 posts
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
  • Has been part of the Envato Community for over 5 years
  • Has sold $40,000+ on Envato Market
+4 more
Orbital_Themes says

One small suggestion is that you probably shouldn’t flush_rewrite_rules on every page load. This should be done only once when an option for rewrite slug is changed.

2175 posts
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
  • Interviewed on an Envato blog
+10 more
revaxarts says

One small suggestion is that you probably shouldn’t flush_rewrite_rules on every page load. This should be done only once when an option for rewrite slug is changed.

+1 please never call it on every page load :crying:

210 posts
  • Located in Canada
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
+5 more
DanyDuchaine says

Ok I won’t I won’t :)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by