我有三个模型:一个用户,一个帖子,和一个跟踪,它记录一个用户跟踪另一个用户的时间。我想按用户显示当前用户所遵循的所有帖子。邮件列表应按时间戳顺序排列。但是,列表似乎按用户id分组,然后按时间戳排序。我如何才能得到所有的帖子,后面的用户只订购了时间戳?
followed_users = Follow.query.filter_by(follower_id=current_user.id).all()
followed_posts = []
for i in followed_users:
followed_posts.extend(Post.query.filter(Post.autho
我已经用CPT插件创建了一个自定义post类型'CPT_A'。我还为'CPT_A'创建了自定义分类法‘CPT_A’和‘CPT_B’。我有‘Posts’,‘Posts’,‘Posts’,‘Posts’,'Post_E'的'CPT_A'的帖子,并指定'Post_A','Post_B','Post_C‘’CPT_A‘和'Post_D',“‘Post”转到类别B’。
我已经创建了存档页面‘存档-CPT_A.php’来显示'CPT_A' post类型的所有帖子。WP a
我有一张帖子的表格。我显示了按时间降序分页组织的帖子列表,每个页面限制为20行。如何通过id确定特定行在哪个页面上,以便可以链接到该特定页面。
表post
CREATE TABLE post
(
id serial NOT NULL,
text character varying(1000),
created_date timestamp without time zone,
CONSTRAINT post_pkey PRIMARY KEY (id)
)
当前
select * from post order by created_date desc limit 20 offs
我有个Post模型。具有查找启用的帖子的作用域。帖子可以属于某个类别。我也有一个Category模型,有类别排名。类别有很多帖子。我想首先显示属于不同类别的20个不同的帖子(这是前20个类别),然后按其published_time的降序显示帖子的其余部分。
这就是我的东西
Post model
class Post < ActiveRecord::Base
belongs_to :categories
scope :by_category, ->(category) { joins(categories).where(categories: { id: category.id })
我做了一个定制的帖子“案例研究”,其中有许多帖子。
我希望获得每个帖子的ID来操作数据,但是尽管查看了类似的线程,但我无法拼凑出一种方法来实现这一点。类似的东西;
foreach post oftype custom, get the id
我正在创建一个函数,在后端显示这些信息,下面是代码片段。
function display_meta_box( $case_study )
{
if (in_array('case_studies', get_post_types()))
{
...get the IDs of all posts of t
假设我正在实现一个博客,并希望根据最新的活动显示最新的帖子(因此新帖子或新评论或新的喜欢上的最新时间戳)。我的对象结构是这样的:
Post
EntityCollection<Comment>
EntityCollection<Like>
现在,我只在Post上按最新的时间戳排序:
public IQueryable<Post> GetPosts()
{
return from post in _db.Posts
orderby post.CreatedDate descendi