#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: #categories #permalinks custom permalinks for category archive ( custom base and no parent slug )

Bounty: 50

For the default taxonomy i.e category , I want custom permalinks with

i) base = "post/c"  and 
ii) without any parent slug

For eg: if I have categories

cat-a
   subcat-a1
   subcat-a2
cat-b
   subcat-a2
   subcat-a2

so I want permalinks like

example.com/post/c/cat-a
example.com/post/c/subcat-a1
example.com/post/c/subcat-a2
example.com/post/c/cat-b
example.com/post/c/subcat-b1
example.com/post/c/subcat-b2

I am using the following code .. I solves the issue (ii) but not issue (i) i.e base ‘post/c’

add_filter('term_link', 'ojasya_no_term_parents', 1000, 3);
function ojasya_no_term_parents($url, $term, $taxonomy) {
if($taxonomy == 'category'){
$term_nicename = $term->slug;
$url = trailingslashit(get_option( 'home' )) . user_trailingslashit( $term_nicename, 'category' );
}
return $url;
}
// Add our custom post cat rewrite rules
add_filter('rewrite_rules_array', 'ojasya_no_category_parents_rewrite_rules');
function ojasya_no_category_parents_rewrite_rules($rules) {
$new_rules = array();
$terms = get_terms( array(
'taxonomy' => 'category',
'post_type' => 'post',
'hide_empty' => false,
));
if($terms && !is_wp_error($terms)){
foreach ($terms as $term){
$term_slug = $term->slug;
$new_rules[$term_slug.'/?$'] = 'index.php?category='.$term_slug;
$new_rules[$term_slug.'/page/([0-9]{1,})/?$'] = 'index.php?category='.$term_slug.'&paged=$matches[1]';
$new_rules[$term_slug.'/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?category='.$term_slug.'&feed=$matches[1]';
}
}
return $new_rules + $rules;
}

Please help me out on this . Thanks in advance


Get this bounty!!!