有没有可能改变Genesis框架的循环结构,使循环头部出现在与条目内容相同的div中?
我已经尝试过在genesis模板中修改loop.php文件,也尝试过查找不同的钩子,但似乎找不到任何有用的东西。
有没有人已经做到了这一点,或者会有一个想法?
发布于 2014-09-05 01:11:36
要在Genesis中自定义循环,请在需要删除Genesis循环之前:
remove_action( 'genesis_loop', 'genesis_do_loop' );然后,您可以添加自定义循环
add_action( 'genesis_loop', 'my_custom_loop' );以下是Genesis中“标准外观”循环工作的基本示例:
function my_custom_loop() {
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// Your Code Here
<?php endwhile; ?>
<?php endif; ?>
<?php
}
genesis();
?>请注意,您的函数必须以'genesis();‘结尾才能工作!
因此,整个页面代码可以是:
<?php
/*
* Your Custom Page
*/
?>
<?php
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'my_custom_loop');
function my_custom_loop() {
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// Your Code
<?php endwhile; ?>
<?php endif; ?>
<?php
}
genesis();
?>希望它能有所帮助;)
发布于 2015-09-11 13:28:03
下面是一种简单的方法。首先从标题中删除条目标题内容。
例如:
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );一旦标题标记以及条目标题和条目信息从顶部移除。
例如:
add_action( 'genesis_entry_content', 'genesis_do_post_title' );希望这能有所帮助。如果你遇到任何问题,请告诉我。
对不起,忘记添加,您将需要添加此自定义代码在您的子主题的functions.php文件,如果你想它影响到整个网站。如果您希望在某些模板上执行此操作,请在Genesis的子主题中的模板文件中执行此操作。
发布于 2017-09-09 03:34:04
我列出了我在开发网站时使用的所有最常见的Genesis钩子和过滤器,而不是让你厌烦更多的内容。https://icodefy.com/common-genesis-hooks-filters/
https://stackoverflow.com/questions/24872743
复制相似问题