0
私は使用したいワードプレスコードを持っていますが、私はそれにスタイリングをいくつか与えようとしています。それは//ここにを自分のものをやると言う。すなわちいくつかのWordpress PHP内のCSSスタイリング?
<?php global $post;
$current_post = $post; // remember the current post
for($i = 1; $i <= 1; $i++):
$post = get_previous_post(); // this uses $post->ID
setup_postdata($post);
// do your stuff here
the_excerpt();
endfor;
$post = $current_post; // restore ?>
は、私がthe_excerptするパーマリンクやCSSスタイルを追加する必要があります。現在、the_excerptは私のブログのサムネイルをプルアップしています。
これは私が2つのランダムなサムネイルを取得するために使用するコードです。うまくいけば、これは私に上記のコードのためのアイデアを与えるでしょう。 IDやクラスを持つdivタグのセットで
<?php
$args = array('numberposts' => 2, 'orderby' => 'rand');
$rand_posts = get_posts($args);
foreach($rand_posts as $post) : ?>
<div class="postgallery" id="post-<?php the_ID(); ?>">
<a class="title" href="<?php the_permalink() ?>" rel="bookmark"><?php the_excerpt(); ?>
<?php
$thetitle = $post->post_title; /* or you can use get_the_title() */
$getlength = strlen($thetitle);
$thelength = 35;
echo substr($thetitle, 0, $thelength);
if ($getlength > $thelength) echo "...";
?>
</a><?php if ($options['tags']) : ?><?php endif; ?>
</div>
<?php endforeach; ?>
私たちのWordPressサイトでもっと良い回答が得られるかもしれません。質問を移行したい場合はフラグを立ててください(クロスポストしないでください)。ありがとう。 – Kev