Same editable region/content same on all pages - wordpress

I'm working on this website in WordPress and I want the content with the title "Featured Business" that's on the sidebar to appear on all pages. I created a template for it but it doesn't display when called. The code is as shown below.
<div id="ftb">
The content
</div>
<!-- End FTP -->
and I called it with <?php get_ftb(); ?> But it doesn't show.

If you want to display a chunk of html that's part of the sidebar (but not the entire sidebar), I recommend to place it on functions.php, like this:
<?php
function get_ftb() {
?>
<div id="ftb">
The content
</div>
<!-- End FTP -->
<?php } ?>
After that you'll be free to call it with get_ftb();
If you just need to call the entire sidebar, use get_sidebar() instead.

Related

WordPress and Visual Composer custom page template

I really hope somebody can help me.
I'am working with visual composer and whould like to create a template to use on some page's.
I whant to create the first section in pure code and save it in my theme's as a template file.
Then when i pick this template in the page editor, i whould like to use visusal composer, but content made with composer should go below, what i have done in my theme's templatefile.
So if my template file in my theme folder contains a big image and some buttons, then i whant to output visual composer content below it.
Is that at all possible.?
When i try to pick another template file then the default i just get a blank output containing header and footer but no content from visual composer. When i use the default template, all works.
I whant to create a file where i can tell visual composer where to output content, hope it makes sense.
Kind regards
Dannie
Yes this is possible.
Below is a code-example of the template file where you can add your custom code wherever you like.
Name your file like this example-page.php
The ID's and classes are of course optional.
<?php
// Template Name: Your name
get_header(); ?>
<!-- Your custom code goes here -->
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<div class="container">
<!-- Or here, if you want it inside your container -->
<div>
<?php
while ( have_posts() ) : the_post();
the_content(); // Will output the content of visual composer
endwhile; // End of the loop.
?>
</div>
</div><!-- END container -->
</main><!-- #main -->
</div><!-- #primary -->
Need more instructions? Please let me know :)

Drupal - Block body is not saved/shown

i added this in my Drupal theme:
<div id="sidebar">
<?php print $sidebar; ?>
</div>
Additionally I added this in the .info file:
regions[sidebar] = Sidebar
I then created a new block with "Add block" in the admin panel and assigned the created Block to the sidebar. Unfortunately everything i wrote in the block body is not saved and therefore the sidebar does not show any contents. If I update the block body and click on save and go into edit mode to have a look, the block body is empty.
Anybody knows why this happens and how i can solve this?
Thanks.
If this is in your page.tpl.php, you should be using $page['sidebar'] rather than just $sidebar. You also have to call render() on the region. Lastly, it's a good idea to check if it's defined first. For instance:
<?php if($page['sidebar']): ?>
<div id="sidebar">
<?php print render($page['sidebar']) ?>
</div>
<?php endif ?>
Don't forget to clear the cache after adding a new region as well.
See the Bartik theme's page.tpl.php for a more complete example: http://cgit.drupalcode.org/bartik/tree/templates/page.tpl.php.

create a different index.php for post in wordpress

I'm working on a wordpress that has, among other things, a Front Page and a Post Page for showing news.
From what I understand, the template that the Post Page uses, is the index.php, but the index.php is also used by other pages.
The thing is that I want to create a special page for post, with a header that says news, etc., but I don't want other pages to use that template.
Is there a way to create an alternative index.php (index_news.php) that is only used to show posts?
That way I can use index_news.php for the post and index.php for everything else.
Thanks
EDIT //////////
My first option was to create a new page-template (news.php) with the loop inside, and then, in the the wordpress options, targeted the post to that new page (news.php).
But when I do that, it loads the index.php not the news.php template. Maybe is something wrong with the loop. Here is the loop I'm using:
<!-- Start the Loop. -->
<div class="post">
<!-- Display the Title as a link to the Post's permalink. -->
<h2><?php the_title(); ?></h2>
<!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
<!-- Display the Post's content in a div box. -->
<div class="entry">
<?php the_content(); ?>
</div>
<!-- Display a comma separated list of the Post's Categories. -->
<p class="postmetadata">Posted in <?php the_category(', '); ?></p>
</div> <!-- closes the first div box -->
<!-- Stop The Loop (but note the "else:" - see next line). -->
<?php endwhile; else: ?>
<!-- The very first "if" tested to see if there were any Posts to -->
<!-- display. This "else" part tells what do if there weren't any. -->
<p>Sorry, no posts matched your criteria.</p>
<!-- REALLY stop The Loop. -->
single.php - is for one post view, but if You wolud like to modify blog index, than you could also create a custom template (page-news.php) with a header that allows it to be separated as page template:
<?php
/*
* Template Name: News Page
* #package WordPress
*/
?>
and then use loop inside of it.
But for this case what I think is even better, You can modify header.php and use wordpress conditional tags such as:
is_front_page(), is_page() or any that will work for You: http://codex.wordpress.org/Conditional_Tags
There are many ways to do same ;).

Drupal front page - two columns for most recent news

I have graphical project of three-column Drupal front page which has first column for one piece of custom content and two other colums designed for most recent news (one content type) as it is shown on image below:
I am quite new to Drupal and so far I created my own page.front.tpl.php in my PHPTemplate theme with regions like header, footer, menu, search_box etc and content of course. Now I have problem with $content region, in which there should be columns as I described above. My question is: How do I style them (CSS? somewhere in Drupal's admin? use separate blocks? Some module?) to look like in project?
page.front.tpl.php fragment:
<?php if ($content): ?><div class="content-middle"><?php print $content; ?></div><?php endif; ?>
Output simplified HTML structure (so far only two most recent news), I want to style this somehow:
<div class="content-middle">
<div class="node">
<h2 class="title">
<div class="content">
<div class="node">
<h2 class="title">
<div class="content">
You can create 3 new sections in your theme. Modify your .info file (for example MyThemeName.info) and write the following :
regions[content_center_left] = Left Sidebar
regions[content_center_middle] = Middle Sidebar
regions[content_center_right] = Right Sidebar
The next step is to modify your page.tpl.php or if you want these sections to be available only in front page you can modify page-front.tpl.php. Write the following where you want the sections to be displayed:
<?php if ($content_center_left): ?>
<div class="content-left">
<?php print $content_center_left?>
</div><!-- /content_center_left -->
<?php endif; ?>
<?php if ($content_center_middle): ?>
<div class="content-middle">
<?php print $content_center_middle?>
</div><!-- /content_center_middle -->
<?php endif; ?>
<?php if ($content_center_right): ?>
<div class="content-right">
<?php print $content_center_right?>
</div><!-- /content_center_right -->
<?php endif; ?>
Now you can create your views (as blocks) and display them in these sections.
I recommend using the Panels module.
From the project page:
The Panels module allows a site administrator to create customized
layouts for multiple uses. At its core it is a drag and drop content
manager that lets you visually design a layout and place content
within that layout. Integration with other systems allows you to
create nodes that use this, landing pages that use this, and even
override system pages such as taxonomy and the node page so that you
can customize the layout of your site with very fine grained
permissions.
Agreed with Laxman 13 , Panels is definitely the way to go, you could double it with the Views module , which would allow you to retrieve the most recent news or whatever query you may have for you content display.

Creating custom page templates

I have just created my "About Us" page inside WP Admin Dashboard, that points to an about-us.php page template that I created and has a empty div content, i.e.
<div id="content"></div>
It is in here where I would like to grab the content that the wp-admin user enters in the dashboard About Us page and place this content within my
<div id="content">[Dashboard About Us Page Content to go Here]</div>
Basically want to take the whole content from the "About Us" WordPress page and feed this into my about-us.php page template content DIV.
How can I achieve this?
<?php if(have_posts()): while(have_posts()): the_post();
the_content();
endwhile; endif; ?>
Stick that inside the empty div and it will pull the content in dynamically. Read more about the loop here:
http://codex.wordpress.org/The_Loop

Resources