PHP code example of kayue / kayue-wordpress-bundle
1. Go to this page and download the library: Download kayue/kayue-wordpress-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kayue / kayue-wordpress-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Kayue\WordpressBundle\KayueWordpressBundle(),
);
// ...
}
public function firstPostAction()
{
// Method 1: Switch current blog's id. Similar to WordPress's `switch_to_blog()` method.
// Changing the current blog ID will affect Twig extensions too.
$blogManager = $this->get('kayue_wordpress')->getManager();
$blogManager->setCurrentBlogId(2);
$this->getRepository('KayueWordpressBundle:Post')->findOnePostById(1);
// Method 2: Use entity manager if you don't want to switch the entire blog.
// This won't change the current blog ID.
$blogId = 3;
$anotherBlog = $this->get('kayue_wordpress')->getManager($blogId);
$posts = $anotherBlog->getRepository('KayueWordpressBundle:Post')->findOneById(1);
}
use Kayue\WordpressBundle\Wordpress\Shortcode\ShortcodeInterface;
class GalleryShortcode implements ShortcodeInterface
{
public function getName()
{
return 'gallery';
}
public function($attr, $content = null)
{
// do your things...
return "<p>Return HTML</p>";
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.