カテゴリー : WordPress

Wordpressでイベント告知サイトを作るときに役立つプラグイン

行きつけのライブハウスのサイトをベタhtmlからWordpressに移行する作業をしました。
けっこうプラグインを駆使したのでメモっときます。

Article Templates

postやpageを新規作成するときに、あらかじめ決めておいたテンプレートが自動で出てくるプラグイン。

Compact Monthly Archive Widget

月別アーカイブリストをシンプルにするプラグイン。

Custom Query String

カテゴリや月別アーカイブ、年別アーカイブ…毎に表示順(ASC/DESC)を設定できるプラグイン。
イベントリストで、月別アーカイブで日付が新しい順(DESC=30→29→28…)に並んでるのはちょっと気持ち悪い。カレンダー通りに並べたい。
プラグイン使わずにできそうだけど、できなかったので使いました。

Duplicate Post

postやpageを一覧ページ/編集画面からコピーできる。日付と投稿スラッグ以外(All One Seo Packのmeta系も)まるごとコピー出来るので、使いどころによっては超絶便利。

No Future Posts

未来の日付の記事を表示できるようにするプラグイン。助かりました。


Wordpressは最近非の打ち所がなくなってきたように思えます。
もうウェブ作りには手放せないですね。

***

ちなみにWordpress化したライブハウスのサイトはここです。
http://www.crowbar.jp/

Wordpressで関連する記事を表示するコード

カテゴリIDがたとえば186のときの記事に「関連する記事」を表示する、single.phpに埋め込むコード。
関連記事の表示は、JRelatedプラグインを使えばもっとすんなり導入できるので、今後使わないだろうけど、いつか使うようになったときのためのメモです。

<?php if (in_category(‘186′)): ?>
<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo ‘<div style=”background:#efefef; width:100%; clear:both; float:left; margin:15px 0″><h5 style=”margin:1px auto 1px 4px; font-size:10px;”>&raquo; 関連する記事</h5></div><ul>’;
$first_tag = $tags[0]->term_id;
$args=array(
‘tag__in’ => array($first_tag),
‘post__not_in’ => array($post->ID),
’showposts’=>5,
‘caller_get_posts’=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php if (in_category(‘186′)): ?>
<li><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title_attribute(); ?>”><?php the_title(); ?></a></li>
<?php endif; ?>
<?php
endwhile;
}
wp_reset_query();
}
?>
</ul><?php endif; ?>

Wordpressの記事をコピーするボタン:Duplicate Post

Wordpressで、同じような記事を投稿することがあって、その都度タグやカテゴリーを設定するのが面倒だなーと思ってたら、記事、タグ、カテゴリー、抜粋をまるごとコピーするボタンを設置するプラグインがありました。
http://wordpress.org/extend/plugins/duplicate-post/

出来れば投稿スラッグと日付もコピーできるようにしてほしいものですが、それでも作業が相当にラクになりました。ありがとう。

Wordpressで抜粋 excerpt のpタグを取り除くプラグイン

WordPressのテーマ内でを使った時に自動挿入されるpタグを取り除くことができるプラグインがあったのでメモ。

WordPressそのものを改造する方法もあるけど、バージョンアップする度に作業が必要になるので、プラグインのほうが便利ですね。

AZ store: Wp clean excerpt  - Wordpressプラグイン

http://az-store.nrym.org/download/script/wp-clean-excerpt/

Wordpress : get_postsでTagも条件分岐!

Wordpressで、
特定のカテゴリ内の特定のタグ(Tag)を持つ記事のみを条件分岐ループで抽出したいときには、get_postsが便利。

  • <?php $posts=get_posts(‘numberposts=-1&category=186&tag=findaway&orderby=title‘); ?>
    <?php if($posts): foreach($posts as $post): setup_postdata($post); ?>

    • ↓ここには表示したい内容。ここがループするので必要に応じて変えます。
      <a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php printf(__(‘%s’), the_title_attribute(‘echo=0′)); ?>”><?php the_title(); ?></a>

    <?php endforeach; endif; ?>

  • numberpostsは表示したい記事の数。-1で全件抽出。
    categoryカテゴリーID
    tagにはタグのスラッグを。
    orderby表示順(ソート)。上のは記事のタイトル順。

上のを含めた条件分岐ワザの詳細は以下をどうぞ。
Wordpress Codexからの引用ですが、毎度忘れて検索して探すの苦労するから自分用メモです。
http://codex.wordpress.org/Template_Tags/get_posts


$numberposts
(integer) (optional) Number of posts to return. Set to 0 to use the max number of posts per page. Set to -1 to remove the limit.

Default: 5
$offset
(integer) (optional) Offset from latest post.

Default: 0
$category
(integer) (optional) Only show posts from this category ID. Making the category ID negative (-3 rather than 3) will show results not matching that category ID. Multiple category IDs can be specified by separating the category IDs with commas – but an array of IDs does not work.

Default: None
$category_name
(string) (optional) Only show posts from this category name or category slug.

Default: None
$tag
(string) (optional) Only show posts with this tag slug. If you specify multiple tag slugs separated by commas, all results matching any tag will be returned. If you specify multiple tag slugs separated by spaces, the results will match all the specified tag slugs.

Default: None
$orderby
(string) (optional) Sort posts by one of various values (separated by space), including:
  • 'author' – Sort by the numeric author IDs.
  • 'category' – Sort by the numeric category IDs.
  • 'content' – Sort by content.
  • 'date' – Sort by creation date.
  • 'ID' – Sort by numeric post ID.
  • 'menu_order' – Sort by the menu order. Only useful with pages.
  • 'mime_type' – Sort by MIME type. Only useful with attachments.
  • 'modified' – Sort by last modified date.
  • 'name' – Sort by stub.
  • 'parent' – Sort by parent ID.
  • 'password' – Sort by password.
  • 'rand' – Randomly sort results.
  • 'status' – Sort by status.
  • 'title' – Sort by title.
  • 'type' – Sort by type.

Notes:

  • Sorting by ID and rand is only available starting with Version 2.5.
Default: post_date
$order
(string) (optional) How to sort $orderby. Valid values:

  • 'ASC' – Ascending (lowest to highest).
  • 'DESC' – Descending (highest to lowest).
Default: DESC
$include
(string) (optional) The IDs of the posts you want to show, separated by commas and/or spaces. The following value would work in showing these six posts:

  • ‘45,63, 78 94 ,128 , 140′

Note: Using this parameter will override the numberposts, offset, category, exclude, meta_key, meta_value, and post_parent parameters.

Default: None
$exclude
(string) (optional) The IDs of any posts you want to exclude, separated by commas and/or spaces (see $includeparameter).

Default: None
$meta_key and $meta_value
(string) (optional) Only show posts that contain a meta (custom) field with this key and value. Both parameters must be defined, or neither will work.

Default: None
$post_type
(string) (optional) The type of post to show. Available options are:

  • post – Default
  • page
  • attachment
  • any – all post types
Default: post
$post_status
(string) (optional) Show posts with a particular status. Available options are:

  • publish – Default
  • private
  • draft
  • future
  • inherit – Default if $post_type is set to attachment
  • (blank) – all statuses
Default: publish
$post_parent
(integer) (optional) Show only the children of the post with this ID

Default: None
$nopaging
(boolean) (optional) Enable or disable paging. If paging is disabled, the $numberposts option is ignored.

Default: None
TOP
[link] フローリング | 建築 | 住宅 | 設計 | 戸建賃貸 | 土地有効活用 | 美容室 | 美容院 | 空心堂 | 宝塚設計 | 埼玉アジアン | 埼玉戸建 | フリーペーパー | 埼玉求人 | 若者求人 | 建築 | 仕事 | 税金