WordPress.org

Plugin Reviews

Auto Generate Title

Want to save time. Do not want to write TITLE manually. This plugin is for you. No need to write the title. It will generate Post Title from your Post

1 review
Average Rating
5 out of 5 stars
Someting went wrong problem with punjabi/hindi laguages improvement
By ,

pls replace the agt.php..with below ones..on current plugin when we add post in punjabi/hindi laguage it gives Something went wrong.becuase of incomplete words sent to title..
below edit will extract 10 words from post content and set it as title..thanks for this userful plugin.
<?php
/*
Plugin Name: Auto Generate Title
Author: Jatinder Pal Singh
Version: 1.1
Tags: post title, title, automatic, generator
Requires at least: 3.0.1
Tested up to: 4.1
Stable tag: 1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Description: Auto Generate Title from the POST Content. If you leave Title blank, it will use the text written in [agt][/agt] within your post content. If you do not mention these shortcodes in your post, It will pick up first 30 characters from the post.
*/

add_shortcode("agt", "agt_shortcode");
function agt_shortcode( $atts, $content = null ) {
return $content;
}

add_filter( 'wp_insert_post_data' , 'auto_generate_title' , '99', 2 );

function extractTitle($post_content) {
global $words_to_extract;
$post_str = ltrim($post_content);

$arri = explode(' ', $post_str);
$deep=0;
$post_title = '';
foreach($arri as $titlei) {
if ($deep<=$words_to_extract) {
$post_title .= $titlei.'-';
}
$deep++;
}
$post_title= rtrim($post_title,'-');
$post_title = str_replace(array('\'', '"',"\n"), '', $post_title);
return $post_title;
}
$words_to_extract = 10;
function auto_generate_title( $data , $postarr )
{
$title_of_post = ltrim($data['post_title']);
$length_of_title = strlen($title_of_post);
$postdata = ltrim($data['post_content']);
if($length_of_title<1)
{
$matchPattern = "/\[agt\](.*?)\[\/agt\]/";
preg_match_all($matchPattern, $postdata, $foundIt, PREG_PATTERN_ORDER);
if (isset($foundIt[1][0]))
$data['post_title'] = $foundIt[1][0];
else
$data['post_title'] = extractTitle($data['post_content']);
}
return $data;
}
?>

You must log in to submit a review. You can also log in or register using the form near the top of this page.