Class: Wptools::WpPost
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Wptools::WpPost
- Defined in:
- lib/wptools/wp_post.rb
Overview
wp_posts: 投稿などを保存 id: 投稿ID post_title: タイトル post_content: 本文 post_status: 公開情報 post_date: 公開日時(Timeクラス。2020-03-19 11:00:08 UTCと表示されるが実際は日本の時刻?) post_name: slug(テーブル全体でユニーク wordpress.stackexchange.com/questions/305371/how-to-add-two-same-slug-under-two-category)
Constant Summary collapse
- STATUS_PUBLISHED =
'publish'
- STATUS_FUTURE =
'future'
- STATUS_DRAFT =
'draft'
- STATUS_PENDING =
'pending'
- STATUS_PRIVATE =
'private'
- STATUS_TRASH =
'trash'
- STATUS_AUTO_DRAFT =
'auto-draft'
- STATUS_INHERIT =
'inherit'
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.published_posts ⇒ Object
59 60 61 |
# File 'lib/wptools/wp_post.rb', line 59 def self.published_posts where(post_type: 'post', post_status: STATUS_PUBLISHED) end |
Instance Method Details
#categories ⇒ Object
67 68 69 |
# File 'lib/wptools/wp_post.rb', line 67 def categories wp_term_taxonomies.categories.map { |wp_term_taxonomy| wp_term_taxonomy.list }.flatten end |
#dispose ⇒ Object
75 76 77 78 |
# File 'lib/wptools/wp_post.rb', line 75 def dispose # 状態をtrashに変更 self.post_status = STATUS_TRASH end |
#post_date_str ⇒ Object
71 72 73 |
# File 'lib/wptools/wp_post.rb', line 71 def post_date_str post_date.strftime("%Y/%m/%d %H:%M:%S") end |
#tags ⇒ Object
63 64 65 |
# File 'lib/wptools/wp_post.rb', line 63 def wp_term_taxonomies..map { |wp_term_taxonomy| wp_term_taxonomy.list }.flatten end |