Comments (4)
You either need to grab the information yourself from the database, or you could set up a twig extension and have that extension call the wordpress function, provided you are loading wordpress as well as symfony in your project.
https://symfony.com/doc/master/templating/twig_extension.html
from kayuewordpressbundle.
Thanks for your response, but what do you mean by
provided you are loading wordpress as well as symfony in your project
??
I setup the KayueWordpressBundle, and now want to get post thumbnail.
I am familiar with Twig extensions. But how should I call Wordpress functions from within Twig extension? AFAIK, the Wordpress core is not part of KayueWordpressBundle anymore:
Improved version of the original WordpressBundle. The biggest different is this new KayueWordpressBundle won't load the entire WordPress core, thus all the WordPress template funtions won't be available in your Symfony app. This is also the goal of the bundle; do everything in Symfony's way.
from kayuewordpressbundle.
To load the wordpress core, you need to include wp-load.php. How and where you do this depends on your project. There are some performance implications to loading both symfony and wordpress so it's best not to do it on every page.
Once you've included that file you should have access to wordpress functions and globals.
from kayuewordpressbundle.
Finally I found the solution. Required Twig functions are provided by the bundle itself, out of the box:
{% set img = wp_find_featured_image(post) %}
{% if img is defined and img is not null %}
{% set url = wp_get_attachment_url(img, 'medium') %}
<img src="{{ url }}">
{% endif %}
from kayuewordpressbundle.
Related Issues (20)
- Difficulty linking directly to post HOT 3
- Cannot persist Comment or Post entities HOT 1
- When doctrine:generate:entities - Error on TablePrefixSubscriber.php : getClassAnnotations() must be an instance of ReflectionClass HOT 6
- Incompatibility with doctrine fixtures HOT 9
- Stable release with entity manager support HOT 3
- Attempted to call method "setBlogId" on class "Doctrine\ORM\EntityManager" in vendor/kayue/kayue-wordpress-bundle/Kayue/WordpressBundle/Model/BlogManager.php line 62. HOT 4
- Attachment->getUrl is broken
- [RFC] Gallery shortcode HOT 8
- Tag a new version HOT 2
- How to use this an FOSUserBundle for login HOT 2
- A Token was not found in the SecurityContext. HOT 1
- Sharing Session between symfony and wordpress HOT 9
- Fix 3.x Deprecation warnings before 3.x release
- Missing Service HOT 6
- Override the User type so I can implement an interface
- securety.yml HOT 3
- Composer problems with versions
- Cannot autowire: The class 'Kayue\WordpressBundle\Entity\Post' was not found in the chain configured namespaces App\Entity HOT 1
- Error with Symfony 4.4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kayuewordpressbundle.