Jetpackで投稿した記事に画像がなかった場合に任意の画像をOGP画像で出力する方法

Sponsored Link

Jetpackで出力されるOGP画像のカスタマイズ方法です。
投稿した記事に画像がなかった場合、
デフォルトではhttp://wordpress.com/i/blank.jpgが出力されます。

それを任意のOGP画像を出力する方法です。
Continue reading

JetpackでトップページのOGP画像をカスタマイズする方法

Jetpackの共有でOGPタグを出力させると、
デフォルトではトップページの画像は、
http://wordpress.com/i/blank.jpgが出力されてしまいます。
それを自分の画像にカスタマイズする方法です。
Continue reading

remove_post_type_support

取得する投稿タイプの為に特定の機能のサポートを削除します。全ての機能は、そのような編集画面やメタボックスなどの編集画面の機能エリアに直接関連付けられています。更に、’リビジョン’機能は、投稿タイプがリビジョンを保存するかどうかを指示し、’コメント’機能は編集画面にコメント数を表示するかどうかを指示します。

Continue reading

【jQuery編】wp_list_categoriesのclassにスラッグを含める方法

wp_list_categoriesをカスタマイズして、
liにタグを入れたいと思っていてぐぐったところ、
黄色いおじさんこと、
まがりんの記事wp_list_categoriesのclassにスラッグを含める方法が出てきました。
Continue reading

add_post_type_support

任意の投稿タイプの特定の機能のサポートを登録します。各機能は、例えばエディターやメタボックスなど、投稿編集画面に表示されている対応しているフィールドに直接影響があります。さらに、’リビジョン’機能は投稿タイプがリビジョンを保存するかどうかを指示し、’コメント’機能はコメント数が投稿編集画面に表示するかどうかを指示します。

Continue reading

get_post_format

記事の投稿フォーマットを返します。これは通常ループ内で呼び出されますが、投稿IDが提供されていればどこでも使用することができます。

Returns the post format of a post. This will usually be called in the the loop, but can be used anywhere if a post ID is provided.

get_post_formatのファンクションタグ使用方法

<?php $format = get_post_format( $post_id ); ?>

get_post_formatのパラメーター

$post_id

(integer) (Optional)投稿のID。
デフォルト:現在のループ記事

(integer) (Optional) ID of the post.
Default: current loop post

Returns

Format (string)

投稿のフォーマットが、全くフォーマットが設定されていない場合は、false。
現在定義されている形式のセットは、次のとおりです。

The format of the post, or false if no format is set.
The set of currently defined formats is:

  • aside
  • chat
  • gallery
  • link
  • image
  • quote
  • status
  • video
  • audio

デフォルトのフォーマット(例、通常の投稿)がfalseを返すが、これは’標準’フォーマットとしていくつかの場所で呼ばれることにも注意してください。いくつかのケースでは、開発者が以下のような一貫性を維持するための何かをしたい場合:

Note also that the default format (i.e., a normal post) returns false, but this is also referred in some places as the ‘standard’ format. In some cases, developers may wish to do something like the following to maintain consistency:

$format = get_post_format();
if ( false === $format )
	$format = 'standard';

<?php
/*
 * Pull in a different sub-template, depending on the Post Format.
 * 
 * Make sure that there is a default '<tt>format.php</tt>' file to fall back to
 * as a default. Name templates '<tt>format-link.php</tt>', '<tt>format-aside.php</tt>', etc.
 *
 * You should use this in the loop.
 */

$format = get_post_format();
get_template_part( 'format', $format );
?>

変更ログ

Since: 3.1

ソースファイル

get_post_format()は、wp-includes/post.php内に位置しています。

get_post_format() is located in wp-includes/post.php.

External Resources

  • Post types and formats and taxonomies, oh my! by Otto
  • WordPress 3.1 Post Formats Reference by Lisa Sabin-Wilson
  • Smarter Post Formats? by Dougal Campbell
  • Smarter Post Formats? Use Carrington by Alex King

関連ファンクションタグ

Post Formats: set_post_format(), get_post_format(), has_post_format()

wp_set_object_terms

タームとタクソノミータイプ(タグ、カテゴリー、など)にオブジェクト(投稿、リンクなど)関するものです。それが既に存在しない場合、タームとタクソノミーのリレーションシップを作成します。

Continue reading

register_taxonomy_for_object_type

この関数は既に登録されている投稿タイプに既に登録されているタクソノミーを追加します。それは影響されているオブジェクト名である名前に取得します。それが成功した場合にtrueを返します。
Continue reading

Sponsored Link