WordPress.org

Forums

qTranslate slug with widget
[resolved] No widget slug in the custom post type (7 posts)

  1. serdominik
    Member
    Posted 3 years ago #

    I'm using this plugin:
    http://wordpress.org/extend/plugins/qtranslate-slug-with-widget/
    but for custom post type the panel does not appear to enter the slug of the title

    how can I fix this?

  2. jngabi
    Member
    Posted 3 years ago #

    I second this request too!

    Excelent plugin, by the way... i can't believe qTranslate doesn't have this feature out of the box.

    Thanks.
    Gabi

  3. 3dolab
    Member
    Plugin Author

    Posted 3 years ago #

    Custom post types should be supported in the latest (0.5) release.
    Unfortunately, at the moment I'm unable to test if it's working as expected.
    If so, can you please confirm?

    Meanwhile, I'm marking the topic as solved until further notice of fault

  4. jngabi
    Member
    Posted 3 years ago #

    Hey 3dolab, i installed the update (0.5) but the qTranslate Slug Translation box does not appear on any of the custom post types (pages) i created (old or new)

    I don't think it has anything to do with it, but it might help to know that the custom post types were created using this plugin: http://wordpress.org/extend/plugins/custom-post-type-ui/

    Thanks.

  5. Milber
    Member
    Posted 3 years ago #

    Hi, the good news is you can add the meta box easily enough. Below line 773 add this function for every custom post type:

    add_meta_box( 'qts_sectionid', __( 'qTranslate Slug translation', 'qts_textdomain' ), 'qTranslateSlug_custom_box', '[your-custom-post-type-slug]', 'advanced' );

    The bad news is that any value entered in the slug fields for custom post types do not get saved. Having entered slugs and updated a custom post type, the slug box is empty again and if I check the links nothing has changed indeed :-( . Would be v. happy about any tip that points me into the right direction for solving this.

  6. pabloselin
    Member
    Posted 3 years ago #

    I managed to put the box in some custom type with your instructions. Also I noticed that the inputs where being saved in the database but they didn't appear in the input fields when you saved so I also fixed that in the function that recreates the custom box putting some conditional code in case the Box was dealing with some custom post type.

    However, this does not make the translated slugs available in the frontend, so I will try to search where that stuff is happening and if I find something I will post the code here.

    Here is my corrected and tested function for slug box in metaboxes, you have to replace the older one, near line 780 :

    function qTranslateSlug_custom_box() {
      global $post, $wpdb, $q_config;
      $post_types=get_post_types('','names');
      if ($post->post_type == 'page'){
        $post_type = QTS_PAGE;
      } else if ($post->post_type == 'post') {
        $post_type = QTS_POST;
      } else if (count($post_types) > 0) {
        foreach ($post_types as $post_type) {
    	if ($post_type == $post->post_type ) {
    		$type = QTS_CUSTOM;
    		if ( !current_user_can( 'edit_post', $post_id ))
    			return;
    	}
        }
        if ($type != QTS_CUSTOM)
    	return;
      } else {
        return;
      }//Fixing support for custom post types
      if($type == QTS_CUSTOM){
      	$query = $wpdb->prepare(
    		"SELECT qts_lang, qts_slug
      			FROM {$wpdb->prefix}qtranslate_slug
    			WHERE %d = qts_type
    				AND %d = qts_id"
        , $type, $post->ID);
      $results = $wpdb->get_results($query);
      $slugs = array();
    
      } else {
    
      $query = $wpdb->prepare(
    		"SELECT qts_lang, qts_slug
      			FROM {$wpdb->prefix}qtranslate_slug
    			WHERE %d = qts_type
    				AND %d = qts_id"
        , $post_type, $post->ID);
      $results = $wpdb->get_results($query);
      $slugs = array();
    
      }
      foreach ($results as $res) {
        $slugs[$res->qts_lang] = $res->qts_slug;
      }
  7. pabloselin
    Member
    Posted 3 years ago #

    I don't think this issue is solved yet, my patch only saves the slugs in the database but the permalinks aren't working for custom post types yet or it is not clear for me how to make them work.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • qTranslate slug with widget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic