Plugin」カテゴリーアーカイブ

Recent Posts ExtendedとVK Link Target Controllerを併せて使うとき

Recent Posts Extendedはウィジェット上でカテゴリーを指定して投稿を出力出来る便利プラグインです。

VK Link Target Controllerで投稿のリンクを押下したときに別ページ&別タブにするのは、ここでやりました。

ですが、この対処法はRecent Posts Extendedで出力された投稿には効かないのです・・・

ということで、以下。

いじるファイルはこれ。

../wp-content/plugins/recent-posts-widget-extended/includes/functions.php

その中に、以下のような記述があるところがあります。

$html .= '<h3 class="rpwe-title" id="post-'.get_the_ID().'"><a href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'recent-posts-widget-extended' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . esc_attr( get_the_title() ) . '</a></h3>';

h3 class=”rpwe-title”とかで検索引っ掛けるとすぐ見つかります。多分一箇所しかないので。

それで、この↓部分を

<h3 class="rpwe-title">

こうする。

<h3 class="rpwe-title" id="post-'.get_the_ID().'">

これで大丈夫だと思います。

<?php the_ID(); ?>

だと、上手く取得できないので、上みたいに書いてください。
何でかはあとで調べておきます。

余談:
本当に何でもかんでも別タブにしたいときはこうする。

$html .= '<h3 class="rpwe-title"><a href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'recent-posts-widget-extended' ), the_title_attribute( 'echo=0' ) ) . '" target="_blank" rel="bookmark">' . esc_attr( get_the_title() ) . '</a></h3>';

VK Link Target Controllerのリンクを別タブで出す

VK Link Target Controllerという、個別の投稿のリンクを押下すると投稿詳細ではなく別のページにジャンプ出来るプラグインがあります。

それがどうやら、普通のテーマだと別タブで開かないらしいです。外部リンクにしたいとき面倒。
公式テーマ(Twentyシリーズ)とかはいけるっぽいけど・・

ということで以下の対処。

<?php while (have_posts()): the_post(); ?>
<div class="entry">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<span><?php the_excerpt(); ?></span>
</div>
<?php endwhile; ?>

こういう場合、リンクの親要素に以下のid属性を付与。

<div class="entry" id="post-<?php the_ID(); ?>">

おわり。