<meta name="text:Default Tag" content="" />
{block:IndexPage}<script type="text/javascript">
var url = location.href;
if (url == "{BlogURL}") {
window.location = "{BlogURL}tagged/{text:Default Tag}";
}
</script>{/block:IndexPage}
使用mircealungu的建议对我非常有效!以下是我的操作步骤:
1. 找到article标签,并添加类名:
class="notfeatured {TagsAsClasses}"
如果它已经有了一个类名,请在类名引号中添加上述加粗部分。我的最终看起来像这样:
<article id="{PostID}" class="post notfeatured {TagsAsClasses} {PostType}{block:PermalinkPage} {block:Date}not-{/block:Date}page{/block:PermalinkPage}">
2. 找到在 article 标签之前的 div 标签,并添加 classname:
class="{block:TagPage} tag_page {/block:TagPage}{block:PermalinkPage}perma_page{/block:PermalinkPage}"
如果已经存在 classname,则只需将上述加粗部分添加到 classname 引号内即可。我的最终结果是这样的:
<div id="posts" class="{block:TagPage} tag_page {/block:TagPage}{block:PermalinkPage}perma_page{/block:PermalinkPage}" >
3. 最后,在您的CSS中添加以下内容:
article.notfeatured {display: none;}
article.featured, .tag_page article.notfeatured, .perma_page article.notfeatured {display: block;}
您还可以使用JavaScript重新排序显示,以便在列表中首先显示特色文章。脚本非常简单:
$('article.featured').prependTo('#posts');
这里提供一个展示演示的例子。只需将其放置在javascript标签中并将其放置在主题的/body标记之前。在这种情况下,不要使用上面的CSS,因为您不想隐藏帖子。我为脚本实现了一个.top类,并保留了.featured类的CSS,同时使用CSS和脚本。
实际上,这是可能的,但它可能不会按照您的期望工作。
第一步。识别您各个帖子的ID(通常是类似于#post或#entry,让我们称之为#entry)
第二步。用以下内容替换您的开头帖子div: 2nd.添加此CSS代码块
{block:IndexPage}
#entry (or whatever name it is) {display:none}
.featured {display:inline !important}
{/block:IndexPAge}
第三步。将您想在主页上显示的所有帖子标记为“特色”,不要加引号。
这应该可以工作,但很可能会在搜索页面和标签页面上隐藏所有非“特色”帖子,这可能不是您想要的。
如果您希望用户在访问您的博客时被引导到特定的“闪屏页面”,您可以使用jquery重定向脚本。希望这些内容对您有所帮助!
我尝试过许多方法来做这件事,包括使用Tumblr PHP API等。 以下是对我有效的方法:我正在使用Tumblr外部页面,并通过curl php调用加载标记帖子。 它可以通过Ajax完成,但出于SEO原因,我想使用PHP。 以下是代码:
$oath = 'xxx';
$blogName = 'yyy.tumblr.com';
$tag='tagname';
$apiLink = "http://api.tumblr.com/v2/blog/$blogName/posts/?api_key=$oath&tag=$tag";
// Initializing curl
$ch = curl_init( $apiLink );
// Configuring curl options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json') ,
);
// Setting curl options
curl_setopt_array( $ch, $options );
// Getting results
$result = curl_exec($ch); // Getting JSON result string
$data = json_decode($result);
$posts = $data->response->posts;
非常抱歉地说,就目前而言,使用现有的主题选项,您无法实现此功能,否则会严重影响您的SEO声誉。
我知道这是旧的,但我刚刚不得不做到这一点,所以这是我的解决方案。在主题的末尾,在脚本标签中添加:
{block:IndexPage}
$( ".the-posts" ).load( "tagged/home .the-posts article" );
{/block:IndexPage}
其中home
是您为希望在索引页面上看到的文章所赋予的标签。这将基本上将正确的文章加载到帖子div中,替换掉原有的内容。请参阅jquery手册:http://api.jquery.com/load/以获取更多信息。