I am not seeing the content I have for the header region in my drupal theme is it best practice to use the following code in the page.tpl.php?
<?php include('region--header.tpl.php'); ?>
I see the content when I use the code above but I cannot see it when I use the code below:
<?php if ($page['header']): ?>
<?php print render($page['header']); ?>
<?php endif; ?>
In my .info file I have the following code:
regions[header] = Header
Copy your base region.tpl.php file to the theme's templates folder.
region--header.tpl.php file and region.tpl.php file should be placed in the templates folder.
Related
I have a file in my child theme root directory named image-svg.php
The in another file under childthemename/page-templates/filexample.php
I want to include image-svg.php
I tried different ways but the file does no get included:
<?php get_template_part('africa-map-svg.php'); ?>
<?php include('africa-map-svg.php'); ?>
How can I include this file ?
You can use get_template_directory to retrieve the directory of the current theme.
<?php require get_template_directory().'/africa-map-svg.php'; ?>
You can use following function to include any file. get_theme_file_uri()
please try this
<?php require_once (get_theme_file_uri('/africa-map-svg.php')); ?>
I am new in Wordpress. I am developing my own theme. I have included index.php, functions.php, header.php, footer.php, page.php, style.css etc.. Now my home page is working perfectly. When I am going to display category menu its showing only header and footer. Not inside the content. When displaying post also its showing Header and footer.
What are the steps included for displaying posts in theme development or is there any function I want to include in function.php ?
You need to use "the loop" to display the content from the page/post.
<?php get_header(); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<article>
<header><h1><?php the_title();?></h1></header>
<?php the_content(); ?>
</article>
<?php endwhile; ?>
<?php endif; ?>
<?php get_footer(); ?>
Copy this code into a new file called single.php in your theme folder.
Best way is to copy the existing theme and change the theme name ( make changes in css , images , header , footer design ) and use that , it will work correctly.
If you are working with child theme.
than all pages display under default template. and default template is page.php.
for category there is a category.php or archive.php file in which you have to change code for more functions.
And for display post you have to change single.php
you can create template for additional functionality.
that's it.
You might be missing content.php, category.php,content-single.php and many more files which in result not displaying your content part and only displaying header and footer.
Best way is download fresh word press from :
https://wordpress.org/download/
It will include all supporting files for load website.copy one of theme from fresh themes folder and replace it with your theme and customise in it.
I have added a php page (test.php) in my root directory (WWW) where wordpress is installed. I don't want to use the custom template method (add this page in my wordpress theme directory)
I have added in this php file this:
<?php
require('wp-blog-header.php');
get_header();
?>
<h1>Test</h1>
<?php
get_footer();
?>
When I do: www.example.com/test.php this page is correctly loading but the title of this page display "error 404"
I don't understand how can I resolve this problem.
you need to include wp-load.php to use header, in your case replace require('wp-blog-header.php'); with
<?php require_once('wp-load.php'); ?>
I have placed this code in my root directory in test.php file. This code is working fine if you replace require('wp-blog-header.php'); with require_once('wp-load.php');
I'm trying to incorporate some custom made php files in a WordPress site.
In these files made links to other files.
<?
echo "" $row['Name'] . "<br> ";
?>
This works fine with an php-execute plugin for WordPress. The only thing is that the show.php opens without the WordPress theme and layout.
How can I make a link so that a new php file will open in the same (side)bar/frame with the same layout as the WordPress page?
you need to create a custom template for that
The syntax is something like this:
<?php
/*
Template Name: My Custom Page
*/
get_header();
?>
Here your HTML coding goes
<?php get_footer(); ?>
This will give you the look and feel you are looking for!!
Found my own work around
Create a page in WordPress (page_id=x) and include an exec-php plugin.
Include this code on the page.
<?
$page_include =$_GET["page_include"];
include $page_include;
?>
If you want to show a custom page in the wordpress them make the following link:
<?
echo " link "
?>
I want to distribute my page contents in various files for a wordpress theme. As I can do with header, sidebar and footer.
Something like
<?php get_imageslidercontent(); ?>
or anything else.
You should put this function in the functions.php file that is in your theme root folder and then you can use your function in your theme