Пример #1
0
 /**
  * (non-PHPdoc)
  *
  * @see \Widgets\WidgetBase::widget()
  */
 public function widget($args, $instance)
 {
     /*
      * Put the pages to show into the instance var.
      */
     $instance['pages'] = Post::getPages();
     /*
      * And call the widget func from the parent class WidgetBase.
      */
     parent::widget($args, $instance);
 }
Пример #2
0
<?php

/*
 * This file is part of the Knob-mvc package.
 *
 * (c) José María Valera Reales <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use Knob\Models\Post;
/**
 * NOTE:
 * For to use this page remember that you have to create your own
 * page through the backend from Wordpress.
 *
 * @example yoursite.com/random
 * @see https://codex.wordpress.org/Template_Tags/get_posts
 */
$posts = get_posts(['post_status' => Post::STATUS_PUBLISH, 'post_type' => Post::TYPE_POST, 'showposts' => 1, 'orderby' => 'rand']);
$post = Post::find($posts[0]->ID);
header("Location: {$post->getPermalink()}");
Пример #3
0
 /**
  * Loop the query and mount the Post objects
  *
  * @param WP_Query $loop            
  * @return array<Post>
  */
 private static function loopQueryPosts($loop)
 {
     $posts = [];
     for ($index = 0; $loop->have_posts(); $index++) {
         $loop->the_post();
         $posts[] = Post::find(get_the_ID());
     }
     return $posts;
 }
Пример #4
0
 /**
  * Get the post relaction with the commnet
  *
  * @return Post
  */
 public function getPost()
 {
     return Post::find($this->comment_post_ID);
 }