timber

Target a specific page template with Timber (WordPress)

霸气de小男生 提交于 2021-02-17 03:19:32
问题 I am trying to output some HTML content on a specific page with a Timber file (.twig). I have been able to output content on the home page but not on a specific page. I tried the following code : % if fn (is_page('proprietes')) %} <h5 class="widget__headline">Test</h5> {% endif %} But I end up with a blank page. I probably made a dump syntax mistake... Thanks for your help. 回答1: Correct way: {% if fn('is_page', page) %} "page" can be slug/id/array of id's etc. 回答2: Try using id instead of

Issue with Post Object Timber/Twig WordPress

♀尐吖头ヾ 提交于 2021-02-11 13:54:07
问题 I have an ACF field, It's a Repeater, and inside the Repeater is a Post Object. Controller /* Template Name: Strategic Partners */ use Timber\Timber; use Timber\PostQuery; use Flynt\Utils\Options; use const Flynt\Archives\POST_TYPES; $context = Timber::get_context(); $context['slider'] = get_field('slider'); $context['featured'] = get_field('featured'); if (isset($_GET['contentOnly'])) { $context['contentOnly'] = true; } Timber::render('templates/StrategicPartners/index.twig', $context); Here

Passing PHP global variables via Twig/Timber

和自甴很熟 提交于 2021-02-11 12:48:55
问题 According to https://stackoverflow.com/a/19554524/6450661, standard Twig provides a method via {{ app.request }} that I can use to pass $_GET, $_POST, $_SESSION, etc. variables. Using Timber, is there a similar method? I can use Timber\URLHelper's get_params() method to access $_GET variables, but that's about all I can seem to find. 回答1: I looked through the source code and at least found the answer for $_GET and $_POST variables, so here it is if it helps anyone. To access $_POST variables,

Passing PHP global variables via Twig/Timber

馋奶兔 提交于 2021-02-11 12:48:02
问题 According to https://stackoverflow.com/a/19554524/6450661, standard Twig provides a method via {{ app.request }} that I can use to pass $_GET, $_POST, $_SESSION, etc. variables. Using Timber, is there a similar method? I can use Timber\URLHelper's get_params() method to access $_GET variables, but that's about all I can seem to find. 回答1: I looked through the source code and at least found the answer for $_GET and $_POST variables, so here it is if it helps anyone. To access $_POST variables,

Timber Wordpress - Show blocks of posts from two categories

北战南征 提交于 2021-02-08 10:20:31
问题 I've created a new page-test.php with the following. $query = array('category_name' => 'blog, portfolio'); $context['posts'] = Timber::get_posts($query); This shows posts from just these categories which is great but I want to group these into specific divs on the page. At present I can't get my custom page or tease twig files (I've no idea if I need both or just one) to override the default twig pages. I make changes that either break the page or seem to do nothing. I'm sure this is totally

Timber pagination with custom post type

安稳与你 提交于 2021-02-08 09:42:49
问题 I am trying to use the example shown in the Timber docs for pagination with a custom post type. This is not working as I'd expect. The only way I've gotten a pagination to output is to add query_posts($args); after I set up my query $args and before I pass them into a new Timber\PostQuery but from everything I've read, I shouldn't be doing this. I have read this issue thread, but it seems to rely on using WP_Query directly, and I'm trying to keep this task as simple as possible. Any tips

Timber pagination with custom post type

纵然是瞬间 提交于 2021-02-08 09:41:41
问题 I am trying to use the example shown in the Timber docs for pagination with a custom post type. This is not working as I'd expect. The only way I've gotten a pagination to output is to add query_posts($args); after I set up my query $args and before I pass them into a new Timber\PostQuery but from everything I've read, I shouldn't be doing this. I have read this issue thread, but it seems to rely on using WP_Query directly, and I'm trying to keep this task as simple as possible. Any tips

Using Timber and Shopify, how can I add meta fields on the ajax mini cart of timber?

三世轮回 提交于 2021-01-07 01:21:02
问题 I’m using Timber in a Shopify theme. I would look to add meta fields of the product on the cart. Cart screenshot here The metafields are showing on product i would like to show that on Ajax mini cart too. product page screenshot js code here Let me know if its possible. 回答1: Here are a few examples on how you may access a product's metafields. In the cart page though, because you don't have a direct access to the product object, you should first get access to the product object via the [line

Using Timber and Shopify, how can I add meta fields on the ajax mini cart of timber?

纵然是瞬间 提交于 2021-01-07 01:17:08
问题 I’m using Timber in a Shopify theme. I would look to add meta fields of the product on the cart. Cart screenshot here The metafields are showing on product i would like to show that on Ajax mini cart too. product page screenshot js code here Let me know if its possible. 回答1: Here are a few examples on how you may access a product's metafields. In the cart page though, because you don't have a direct access to the product object, you should first get access to the product object via the [line