如何自定义Wordpress主题标题以更改布局?

I am using the latest version of the Avada theme. I would like to place full-width content (a simple shortcode) in the header area of a page that has sidebars enabled. However, I have found that the theme does not allow you to have full-width content (aside from built-in options like the slide, menu, artwork, etc.), with a page that has sidebars enabled.

A moderator on their user forum wrote this in regards to this limitation:

Going by your screenshot you will have to create a custom solution for that. (referring to the full width section above the page and sidebar content, based on your screenshot) – that would mean creating a std page in WP and then in the header file using PHP to call that page and it's content into position:

    <?php if ( is_front_page() ) { $subPageHeader = new WP_Query("page_id=25″); >while($subPageHeader->have_posts()) : $subPageHeader->the_post(); ?>

This is just a head start.

Here is the screenshot he's referring to: http://i.stack.imgur.com/jHRdn.jpg

The four content items: Our Issues, Our Contract, Opportunities, Q&A is what I'm trying to add.

Unfortunately I only got a partial explanation and am humbly asking for the community's help on achieving this. Thanks in advance.

1个回答

As the moderator said you can make other page and design it as you want and call it into your header.php . It's so simple just make your page by .php format witch it start with:

<?php

and ends with:

?>

then call it like this:

<?php get_template_directory_uri(); ?>

or

<?php echo get_template_directory_uri(); ?>

or even you can call it by functions.php like this:

<?php
function my_scripts_method() {
    wp_enqueue_script(
        'custom_script',
        get_template_directory_uri() . '/js/custom_script.js',
        array('jquery')
    );
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
?>

Just remember to do not call header and footer into your page cause you no want double header into each other.

drgawfsf1069
drgawfsf1069 像这样:<?php do_shortcode('短代码名称'); ?>
5 年多之前 回复
douyannuo7733
douyannuo7733 这四个内容项是从短代码生成的。 如何在php文件中工作?
5 年多之前 回复
duanba7653
duanba7653 四个内容项目:我们的问题,我们的合同,机会,问答是我想要添加的内容。 你只需要在第一个和那个结尾处创建一个包含<?php和?>的HTML页面,然后使用我上面提供的代码将该文件的地址提供给你的标题。 剩下的就是设计你自己制作的自定义页面。 直到你想要只是4个链接或你想要的。 如果你仍然困惑,请看看这个页面可能对你有所帮助:codex.wordpress.org/Child_Themes
5 年多之前 回复
dongyulian5801
dongyulian5801 谢谢Scott的回应。 我确信它很简单,但我不理解你的解决方案,因为我不知道PHP或Wordpress的复杂性。 通过更多的外行解释,我会更好地理解它。 在子主题下,我创建了一个自定义标题模板,并为相关页面应用了自定义页面模板。 在儿童主题。 我该怎么办?
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐