V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
isudng
V2EX  ›  PHP

wordpress 一条功能代码求助

  •  
  •   isudng · 2013-05-31 17:17:19 +08:00 · 3322 次点击
    这是一个创建于 3981 天前的主题,其中的信息可能已经有所发展或是发生改变。
    首先附上项目地址:http://www.itaoclub.com/
    想实现一个功能:在网站首页,如果一个推荐文章在某一分类下,则…………的判断
    网站有个活动场,我想让用户在网站首页点击活动推荐的标题之后跳转到活动页面,如http://www.itaoclub.com/huodon#to=爱尚生活 – 棉麻生活,轻松享受
    但是如果这个推荐是活动预告的话显然需要增加另一种判断.
    当下判断推荐的文章是否为活动还是一般推荐是依赖一个自定义字段.但是这个确实当下只是初步的解决方法.我想让解决更为纯粹点.如果推荐文章是在预告分类下,则跳转到活动预告页面.如:
    http://www.itaoclub.com/yugao#to=韩都衣舍 7周年庆

    水品很有限啊.望大神指教
    6 条回复    1970-01-01 08:00:00 +08:00
    Ebola
        1
    Ebola  
       2013-05-31 17:32:48 +08:00
    is_category()
    isudng
        2
    isudng  
    OP
       2013-05-31 17:53:57 +08:00
    elseif(is_category(2) ){ ?>
    <h2 class="postLink"><a href="yugao#<?php the_title(); ?>" target="_blank" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <?php }


    这样行?
    fyhqy
        3
    fyhqy  
       2013-05-31 18:10:15 +08:00   ❤️ 1
    is_category() 这个是判断 分类页面的。
    你这个是要判断文章的。你可以用 in_category() 来判断是否在这个分类里面
    isudng
        4
    isudng  
    OP
       2013-05-31 22:01:20 +08:00
    @Ebola elseif(is_category(2) ){ ?>
    <h2 class="postLink"><a href="yugao#<?php the_title(); ?>" target="_blank" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <?php }


    这样行?
    jankan
        5
    jankan  
       2013-05-31 23:30:08 +08:00   ❤️ 1
    isudng
        6
    isudng  
    OP
       2013-06-01 09:38:03 +08:00
    @Ebola
    @fyhqy
    @jankan
    已经完全解决: 在推荐列表中,如果这个推荐是活动,则跳转到活动列表中并滑动到这个推荐;如果这个推荐是活动预告,则跳转到活动预告页面并滑动到这个推荐.效果请看
    http://www.itaoclub.com
    在此谢谢你们的帮助.也邀请你们关注我网站的更新
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1048 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:20 · PVG 03:20 · LAX 12:20 · JFK 15:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.