douguangxiang0363 2012-07-03 23:04
浏览 18
已采纳

从帖子标题自动生成关键字

For example I have title "The Battleship Trailer" so it will generate keyword like this "best , player, of, the, world" how can i do it ?

I want to apear in html like this...

First:The
Second:Battleship
Third:Trailer

<meta name="keywords" content="<FirstWord>,<second>,<third>"/> 

More exactly i want to split the title in words.

I use Wordpress

  • 写回答

3条回答 默认 最新

  • douzhuanqian8244 2012-08-08 11:11
    关注

    It might be better to get the post's slug. That will sanitize and strip out any shorter words that won't be of any value to search engines. Then explode and implode with PHP...

    Here how:

     // Get the global post variable (inside or outside the loop)
     global $post;
    
     // Seperate title slug by dashes into array
     $the_slug_into_array = explode('-', $post->post_name);
    
     // Convert array back into a string with comma separation
     $the_keywords = implode(',', $the_slug_into_array );
    
     // Echo out the string of terms from the title
     echo $the_keywords;
    

    Let me know if this worked for you...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探