• Resolved dtszero

    (@dtszero)


    Hi,

    I have a custom permalink config
    mysite.com/%category%/%postname%/

    And I choose a principal category using the Yoast Plugin. With this I using a custom action for the new’s publish/updates of my post’s and send a notification to my social profiles.

    add_action( 'transition_post_status', 'notifications', 10, 3 );
    function notifications ( $new_status, $old_status, $post ) {
      if ( get_post_type($post->ID) !== 'post' ) { $send = false; } else { $send = true; }
      $url = get_the_permalink($post->ID);
    }

    […]

    But, I receive an “incorrect” permalink config when I using the quick edit post function.

    If I use the normal post editor the permalink that I return is
    mysite.com/vacations/china

    But if I use the quick edit the permalink is wrong:
    mysite.com/travels/asia

    The principal category that I choose disappears and is sending the WordPress default alphabetic category as a base.

    Yoast Version: 7.4.2
    WordPress Version: 4.9.5
    PHP Version: 7.0

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    We can’t offer support on custom code (needed to change (core) features of our plugin). Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes. Maybe someone watching these forums can assist you further, but if your topic is inactive for 7 days, we’ll mark it as resolved to keep the overview.

    Thank you for your understanding.

    Thread Starter dtszero

    (@dtszero)

    Thanks for the reply ??

    I looked into you core examples of github and I found a manual code for check this:

    // SHOW YOAST PRIMARY CATEGORY, OR FIRST CATEGORY
    function patch_primary_cat($id){
      $category = get_the_category($id);
      $useCatLink = true;
    	if ($category){
    		$category_link = '';
    		if ( class_exists('WPSEO_Primary_Term') ){
    			// Show the post's 'Primary' category, if this Yoast feature is available, & one is set
    			$wpseo_primary_term = new WPSEO_Primary_Term( 'category', $id );
    			$wpseo_primary_term = $wpseo_primary_term->get_primary_term();
    			$term = get_term( $wpseo_primary_term );
    			if (!is_wp_error($term)) {
    			  // Yoast Primary category
    			  $category_link = get_category_link( $term->term_id );
    			  return $category_link;
    			}
    		}
    	}
    }

    I’m not sure if isn’t pretty but is working for me. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug – Incorrect category on quick edit post’ is closed to new replies.