How to call cms static block in footer.phtml in magento? - magento-1.9

How to call CMS static block in footer.phtml in Magento? kindly help me. for this
i tried to below code but not working
getLayout()createBlock('cms/block')setBlockId('footer')toHtml(); ?>

Hi tried to this may be help.
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('footer')->toHtml(); ?>

Call CMS block like this:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('footer')->toHtml() ?>

Related

How to place multiple lines of code between an open and closing short-code

I am trying to add multiple lines of code in a custom html page template between a shortcode that would restrict the content .
The short-code is:
<?php echo do_shortcode("[wcm_restrict plans="gold, platinum"]Restricted Content[/wcm_restrict]"); ?>
I have tried placing the code in the shortcode like below but with no luck:
<?php echo do_shortcode("[wcm_restrict plans="gold, platinum"]"); ?>
<h1>This is a Heading for demo display</h1>
<p>This is a demo paragraph.</p>
<?php echo do_shortcode("[/wcm_restrict]"); ?>
What would the correct way be for placing multiple lines of code between the shortcode?
<?php echo do_shortcode("[wcm_restrict plans="gold, platinum"]Multiple lines of code here[/wcm_restrict]"); ?>
The issue with your first approach is that your content is outside the shortcode and you're inserting two shortcodes.
Try something like this and let us know:
<?php
$content = '[wcm_restrict plans=\"gold, platinum\"]
<h1>This is a Heading for demo display</h1>
<p>This is a demo paragraph.</p>[/wcm_restrict]';
echo do_shortcode("$content"); ?>
EDIT: As pointed out by rick the double quotes need to be escaped. The answer has been updated to reflect that change.

Wordpress: some page_id redirects to latest post — whats wrong?

I have problem with my wordpress site.For example, my database contains two posts, with ids 10 and 15. When I write:
/?page_id=10 — I get a redirect to page of my post with id 10, nice.
/?page_id=20 — I get a redirect to 404 page. Also nice.
/?page_id=loremimpus — I get a redirect to the latest post, with ID=15. But I need to redirect to 404 page.
Whats wrong, where is a mistake?
Code of my single.php here:
<?php get_header(); the_post(); ?>
<article>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<article>
<?php get_footer(); ?>

Looking to at post to a created page on WordPress

I'm looking to be able to add blog posts to a page I created, as well on the front page too. So, I'd like to have the blog post about sports, show up on my front page and also on my Sports page. Is this possible?
I don't just want to categorize them and tag them, I want it to show on the specific page created for sports.
Any help from you guys would be much appreciated. Thank you!
Here's a few links that might help you along.
http://codex.wordpress.org/Page_Templates
http://codex.wordpress.org/The_Loop
http://codex.wordpress.org/Class_Reference/WP_Query
Try placing this file in your theme folder and choosing it as your template for your page. You'll also need to change the category number at the top. You can refine it further by copying and pasting code from your index.php file in your theme folder. Mix and match elements to get it closer to what you need. Good luck!
<?php
/*
Template Name: Custom Sports Template
*/
get_header();
query_posts( 'cat=3' );
?>
<div id="content" class="widecolumn">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2>
<div class="entrytext">
<?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
<div id="main">
<?php get_search_form(); ?>
<h2>Archives by Month:</h2>
<ul>
<?php wp_get_archives('type=monthly'); ?>
</ul>
<h2>Archives by Subject:</h2>
<ul>
<?php wp_list_categories(); ?>
</ul>
</div>
<?php get_footer(); ?>

Wordpress Page.ly MultiEdit Plugin Not Working

I'm trying to use the Wordpress page.ly MultiEdit plugin here:
http://wordpress.org/extend/plugins/pagely-multiedit/
I can't get it to work correctly. I get an error:
Bottom, Left, Bottom, Left region(s) are not declared in the template.
Here's a screenshot.
Here is the code for the template file I created:
<?php
/*
Template Name: Home
MultiEdit: Right
*/
?>
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="content">
<?php the_content(); ?>
</div>
<div class="sidecontent">
<?php multieditDisplay(‘Right’); ?>
</div>
<?php endwhile; endif; ?>
<?php get_footer(); ?>
Am I missing something?
Thanks.
I guess I didn't look at your code close enough. You're not calling them twice in the code, you're just not calling them at all. You can still follow the instructions in my answer and it will work.
Couple things here. It looks like you're calling the same two content blocks twice in the same page template. You can't do that. Each one has to have its own unique name. If you're simply trying to get "bottom', "left", and "right" you need to change you're comment code at the top of the page template.
Use this:
/*
Template Name: Home
MultiEdit: Bottom,Left,Right
*/
Then place these where you want the content to be displayed in your page template:
<?php multieditDisplay('Bottom'); ?>
<?php multieditDisplay('Left'); ?>
<?php multieditDisplay('Right'); ?>
Before you do any of that though, click on the "Screen Options" tab in the top corner of the admin page for your home page editor. Then click on the "Custom Fields" option. Then scroll down until you see the "Custom Fields" area and expand it. Then click on the "Show/Hide Multiedit Fields" so that you can see the ones you currently have in there. You need to delete each one of them to clear them from your editor. Follow these instructions and it will work, its an amazing plugin that I've used many times with great success. Once you fix it, please accept my answer. Let me know if you have any other issues with it.
Also, you don't need to use the call inside of a loop, just drop in the one of the three calls where you need it to be in the template. In fact, I'd recommend not using it inside of a loop.

Magento wordpress header cms block

I have a small question. I have included a wordpress blog on my magento shop via the fishpig module. This works great but what I want to include are header options via static cms blocks on the blog. I think I need to adjust something in the phtml of the homepage blog.
app/design/frontend/base/default/template/wordpress/homepage.phtml
This is the current code:
<div class="page-title blog-title <?php if (!$this->isFirstPage()): ?>not-<?php endif; ?>first-page<?php if ($this->isFirstPage() && $this->getTagLine()): ?> with-tagline<?php endif; ?>">
<h1><?php echo $this->escapeHtml($this->getBlogTitle()) ?></h1>
</div>
<?php if ($this->isFirstPage() && $this->getTagLine()): ?>
<p class="blog-desc blog-tag-line"><?php echo $this->escapeHtml($this->getTagLine())
?></p>
<?php endif; ?>
<div class="blog-home">
<?php echo $this->getPostListHtml() ?>
</div>
I played arount with the following line of code but I cant get it to work:
echo $this->getLayout()->createBlock('cms/block')->setBlockId('example_block')->toHTML();
Any solution would be great!!
Thanks..
You can display static blocks on the blog page using this code
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('example_block')->toHTML();?>
But first you need to create a static block in the admin panel. Admin-> Cms-> Static blocks. Then, after you have specified for the static block title, identifier, status and content, you'll need to replace the block identifier in your code to the identifier of the block that you created in the admin.
For example, you have created a block with identifier "blog_header" means the code to show this block on frontend, will be the
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('blog_header')->toHTML();?>