#StackBounty: #custom-post-types #custom-field #permalinks #advanced-custom-fields ACF Relationships in Custom Post Type Permalink

Bounty: 100

My problem is one that i can’t seem to find a solution to.

I have 2 Custom Post Types, Mangas and Chapters, every chapter published will always be connected to a manga via the ACF relationship field.

The current permalink structure for the chapter is site.com/chapters/chapter-title and what i want is site.com/mangas/connected-manga/chapter-title

Since wordpress doesn’t offer much in the way of post-to-post relationships the ACF relationship field is great for this and i have everything figured out except for this… the permalink.

Any help would be appreciated. Please bear in mind that i don’t want to use an extra plugin for this.


Get this bounty!!!

#StackBounty: #custom-post-types #custom-taxonomy #permalinks Custom permalink – append taxonomy name and term name at the end of perma…

Bounty: 50

I have

custom post type -> resources
custom taxonomy  -> resources_type

I want custom permalinks where category base will be appended at the end instead of front

For example: I add a new resource with title “First resource” and assign term as type1

What I gethttp://example.com/resources/resources-type/type1/first-resource

What i wanthttp://example.com/resources/first-resource/resources-type/type1

I am using the following argument code in register post type :

'rewrite' => array("slug" => "/resources/resources-type/%resources_type%"),

And then using following code to replace the “%resources_type%” in above code

function wpa_course_post_link( $post_link, $id = 0 ){
  $post = get_post($id);  
  if ( is_object( $post ) ){
      $terms = wp_get_object_terms( $post->ID, 'resources_type' );
      if( $terms ){
        return str_replace( '%resources_type%' , $terms[0]->slug , $post_link );
      }
  }
  return $post_link;  
}
add_filter( 'post_type_link', 'wpa_course_post_link', 1, 3 );


Get this bounty!!!

#StackBounty: #custom-post-types #permalinks 'publicly_queryable' => false not working as expected for custom post_type

Bounty: 50

I have a custom post_type that I registered with the following settings:

  'labels' => piklist('post_type_labels', 'Tattooer')
  ,'title' => __('Enter the name of the tattooer')
  ,'supports' => array(
    'title',
    'editor',
    'thumbnail',
    'page-attributes'
  )
  ,'public' => true
  ,'has_archive' => true
  ,'rewrite' => array(
    'slug' => 'tattooer'
  )
  ,'publicly_queryable' => false
  ,'capability_type' => 'post'
  ,'edit_columns' => array(
    'title' => __('Name')
  )
  ,'hide_meta_box' => array(
    'author'
  )

I don’t want any URLs to single tattooer posts. My understanding is that 'publicly_queryable' => false is the tool for this job. But when I set it to false, the single URL is still active (Ex: /tattooer/foobar/) but redirects to the homepage. I think the intended behavior is that it should be a 404, which is what I want. What am I missing?

Notice that I’m using the wonderful Piklist plugin to expedite the registration of custom post_type(s), but I’ve tested without it as well and the results were the same.

My information is based on the documentation and this very similar question.


Get this bounty!!!

#StackBounty: #custom-post-types #permalinks 'publicly_queryable' => false not working as expected for custom post_type

Bounty: 50

I have a custom post_type that I registered with the following settings:

  'labels' => piklist('post_type_labels', 'Tattooer')
  ,'title' => __('Enter the name of the tattooer')
  ,'supports' => array(
    'title',
    'editor',
    'thumbnail',
    'page-attributes'
  )
  ,'public' => true
  ,'has_archive' => true
  ,'rewrite' => array(
    'slug' => 'tattooer'
  )
  ,'publicly_queryable' => false
  ,'capability_type' => 'post'
  ,'edit_columns' => array(
    'title' => __('Name')
  )
  ,'hide_meta_box' => array(
    'author'
  )

I don’t want any URLs to single tattooer posts. My understanding is that 'publicly_queryable' => false is the tool for this job. But when I set it to false, the single URL is still active (Ex: /tattooer/foobar/) but redirects to the homepage. I think the intended behavior is that it should be a 404, which is what I want. What am I missing?

Notice that I’m using the wonderful Piklist plugin to expedite the registration of custom post_type(s), but I’ve tested without it as well and the results were the same.

My information is based on the documentation and this very similar question.


Get this bounty!!!

#StackBounty: #custom-post-types #permalinks 'publicly_queryable' => false not working as expected for custom post_type

Bounty: 50

I have a custom post_type that I registered with the following settings:

  'labels' => piklist('post_type_labels', 'Tattooer')
  ,'title' => __('Enter the name of the tattooer')
  ,'supports' => array(
    'title',
    'editor',
    'thumbnail',
    'page-attributes'
  )
  ,'public' => true
  ,'has_archive' => true
  ,'rewrite' => array(
    'slug' => 'tattooer'
  )
  ,'publicly_queryable' => false
  ,'capability_type' => 'post'
  ,'edit_columns' => array(
    'title' => __('Name')
  )
  ,'hide_meta_box' => array(
    'author'
  )

I don’t want any URLs to single tattooer posts. My understanding is that 'publicly_queryable' => false is the tool for this job. But when I set it to false, the single URL is still active (Ex: /tattooer/foobar/) but redirects to the homepage. I think the intended behavior is that it should be a 404, which is what I want. What am I missing?

Notice that I’m using the wonderful Piklist plugin to expedite the registration of custom post_type(s), but I’ve tested without it as well and the results were the same.

My information is based on the documentation and this very similar question.


Get this bounty!!!

#StackBounty: #custom-post-types #permalinks 'publicly_queryable' => false not working as expected for custom post_type

Bounty: 50

I have a custom post_type that I registered with the following settings:

  'labels' => piklist('post_type_labels', 'Tattooer')
  ,'title' => __('Enter the name of the tattooer')
  ,'supports' => array(
    'title',
    'editor',
    'thumbnail',
    'page-attributes'
  )
  ,'public' => true
  ,'has_archive' => true
  ,'rewrite' => array(
    'slug' => 'tattooer'
  )
  ,'publicly_queryable' => false
  ,'capability_type' => 'post'
  ,'edit_columns' => array(
    'title' => __('Name')
  )
  ,'hide_meta_box' => array(
    'author'
  )

I don’t want any URLs to single tattooer posts. My understanding is that 'publicly_queryable' => false is the tool for this job. But when I set it to false, the single URL is still active (Ex: /tattooer/foobar/) but redirects to the homepage. I think the intended behavior is that it should be a 404, which is what I want. What am I missing?

Notice that I’m using the wonderful Piklist plugin to expedite the registration of custom post_type(s), but I’ve tested without it as well and the results were the same.

My information is based on the documentation and this very similar question.


Get this bounty!!!

#StackBounty: #custom-post-types #permalinks 'publicly_queryable' => false not working as expected for custom post_type

Bounty: 50

I have a custom post_type that I registered with the following settings:

  'labels' => piklist('post_type_labels', 'Tattooer')
  ,'title' => __('Enter the name of the tattooer')
  ,'supports' => array(
    'title',
    'editor',
    'thumbnail',
    'page-attributes'
  )
  ,'public' => true
  ,'has_archive' => true
  ,'rewrite' => array(
    'slug' => 'tattooer'
  )
  ,'publicly_queryable' => false
  ,'capability_type' => 'post'
  ,'edit_columns' => array(
    'title' => __('Name')
  )
  ,'hide_meta_box' => array(
    'author'
  )

I don’t want any URLs to single tattooer posts. My understanding is that 'publicly_queryable' => false is the tool for this job. But when I set it to false, the single URL is still active (Ex: /tattooer/foobar/) but redirects to the homepage. I think the intended behavior is that it should be a 404, which is what I want. What am I missing?

Notice that I’m using the wonderful Piklist plugin to expedite the registration of custom post_type(s), but I’ve tested without it as well and the results were the same.

My information is based on the documentation and this very similar question.


Get this bounty!!!

#StackBounty: #custom-post-types #permalinks 'publicly_queryable' => false not working as expected for custom post_type

Bounty: 50

I have a custom post_type that I registered with the following settings:

  'labels' => piklist('post_type_labels', 'Tattooer')
  ,'title' => __('Enter the name of the tattooer')
  ,'supports' => array(
    'title',
    'editor',
    'thumbnail',
    'page-attributes'
  )
  ,'public' => true
  ,'has_archive' => true
  ,'rewrite' => array(
    'slug' => 'tattooer'
  )
  ,'publicly_queryable' => false
  ,'capability_type' => 'post'
  ,'edit_columns' => array(
    'title' => __('Name')
  )
  ,'hide_meta_box' => array(
    'author'
  )

I don’t want any URLs to single tattooer posts. My understanding is that 'publicly_queryable' => false is the tool for this job. But when I set it to false, the single URL is still active (Ex: /tattooer/foobar/) but redirects to the homepage. I think the intended behavior is that it should be a 404, which is what I want. What am I missing?

Notice that I’m using the wonderful Piklist plugin to expedite the registration of custom post_type(s), but I’ve tested without it as well and the results were the same.

My information is based on the documentation and this very similar question.


Get this bounty!!!

#StackBounty: #custom-post-types #permalinks 'publicly_queryable' => false not working as expected for custom post_type

Bounty: 50

I have a custom post_type that I registered with the following settings:

  'labels' => piklist('post_type_labels', 'Tattooer')
  ,'title' => __('Enter the name of the tattooer')
  ,'supports' => array(
    'title',
    'editor',
    'thumbnail',
    'page-attributes'
  )
  ,'public' => true
  ,'has_archive' => true
  ,'rewrite' => array(
    'slug' => 'tattooer'
  )
  ,'publicly_queryable' => false
  ,'capability_type' => 'post'
  ,'edit_columns' => array(
    'title' => __('Name')
  )
  ,'hide_meta_box' => array(
    'author'
  )

I don’t want any URLs to single tattooer posts. My understanding is that 'publicly_queryable' => false is the tool for this job. But when I set it to false, the single URL is still active (Ex: /tattooer/foobar/) but redirects to the homepage. I think the intended behavior is that it should be a 404, which is what I want. What am I missing?

Notice that I’m using the wonderful Piklist plugin to expedite the registration of custom post_type(s), but I’ve tested without it as well and the results were the same.

My information is based on the documentation and this very similar question.


Get this bounty!!!

#StackBounty: #custom-post-types #plugins #menus #settings Update menu when saving settings

Bounty: 50

I have a settings page for my plugin in which the user can toggle a custom post type on or off. When the plugin is initialized I then check this setting to see if the custom content type should be registered or not. The
initialize() method is called on the init action:

function initialize() {
  if ($this->setting->get('enable_cpt')) {
    $this->registerPostType();
  }
}

function registerPostType() {
  $args = array(
    ...
  );
  register_post_type('my-custom-cpt', $args);
}

This works as expected, but the problem is that when I’m saving the form the menu item for the custom post type is not updated until I reload the page. Obviously this is because the menu is already created.

I tried to use wp_redirect() after the setting is saved, but I’m not able to set any headers because the output has already started.

Can someone please explain how I can make the menu item for my custom post type update when saving the setting for my plugin?


Get this bounty!!!