Custom template doesn't accept shortcodes - wordpress

I've created a custom template by copying page.php and then removing basically everything except for the CSS link, so it looks like this:
The div on line 20 just puts a red box on the page so I can recognize that this template, and the linked CSS file, are handling the page. (The idea is to create a large blank page where I can put large tables. I don't want any header markup or sidebar markup, etc., to distract attention from the table.)
I see the red box fine, but when I try to insert a shortcode on the page, to insert a table from TablePress, the shortcode isn't processed. I assume I removed something from page.php that is needed to process shortcodes, since a normal new page, that uses page.php, processes the shortcode fine. Does anyone know what I might have removed that killed the shortcodes?
Thanks.

Two thoughts about your code / problem:
1) I think you should not insert the stylesheet link like this. See: https://codex.wordpress.org/Function_Reference/wp_register_style
2) You can insert the shortcode with
<?php
echo do_shortcode('[ShortcodeName]');
?>

Related

drupal 7 panels landing page, how to remove default theme elements

I'm drupal beginner, and can't solve problem with landing page. I create landing page with panels, set custom css code to it but it doesn't look how I want. I see default elements from my theme (header, nav-menu, etc.) on it. I want that layout fill all my page, how can I achieve it?
I have it
I want do like it
well, I found solution for this problem. I use bootstrap 3 sub theme, and there is file who provide page template, it calls node.tpl.php. I just remove string <div class="main-container <?php print $container_class; ?>"> and now it works well.
go to page.tpl.php file, remove the lines that render the header, the logo and the title. They would usually be in an if statement and the varibles are $logo, $site_name, $main_menu, $title.

Identify wordpress blocks

I am trying to edit a wordpress-theme (translations that are hardcoded in the theme etc) and stumble upon a problem here:
How do I identify, where a content block comes from?
Like, if my theme is constructed by 3 files post.php header.php and footer.php (which would make things pretty simple, but in my case it's quite some more files) and the content isn't set there consistently and the naming is neither "semantic", how could I identify that compiled block abc comes from header.php?
Is that something that can be done via Firebug/DevTools?
Although this question is specifically aiming at Wordpress as a system, the same problem occurs with other file-heavy systems like Typo3 or Magento. Isn't there some other routine then opening, searching all existing files?
Thanks for your answers
If your theme is translation-ready, you could try using Poedit. If not, you can identify where a block comes from knowing that:
Header.php: you'll find there all the strings that come in every page of your blog. Normaly Header.php includes all the code from the beginning of the HTML document until body, but it can be different from one theme to another. There may be diferrents headers, like header-gallery.php (for galleries) or similars.
Index.php: That's the index of your blog, normally it includes the code from the BODY of the html document for the index page.
Single.php, Page.php, Content.php, Aside.php or similars: They include the code for the body of every post/page type. For instance, single.php includes the BODY code for the single post. Sometiems, instead of single.php there are another options like content.php, content-wide.php or similars ("content-TypeOfPage.php"
Footer.php: It closes the HTML document for every post/page. Normaly it includes from the last lines before closing the BODY until the closing of the HTML tag.
Functions.php:: Take care editing this one. This file and the other files required/included on it include the code for the settings of the theme and any other functions implemented. For instance, the custom admin pages on the Dashboard are coded there.

Fields disappear for a specific theme

I'm new to drupal, so sorry in advance or any mistake, feel free to correct.
I don't really know what exactly that I have done cause the problem, but content's fields (for all content types)
is not being shown (the pages are empty beside the title).
When I edit the information it appears.
In the past the information appeared.
It happens only for a specific theme (business_theme), for other themes (drupal's default) the info' appears.
any idea or help will be great
You need to assign Main page content block to a region that already exists in your theme.
First; Declare the region in your theme's .info file.
regions[content] = Main Content
Second; Print the region inside your page.tpl.php file.
print render($page['content']);
Last; Assign the Main page content to the region from the Blocks manager page. ?q=admin/structure/block
After further investigation, It seems that when our own theme is being the default, no node.tpl.php is being called (does that makes sense?).
I add the code
<?php
print '<pre>';
var_dump(get_defined_vars());
print '</pre>';
?>
to each node*.tpl.php file and cleared all caches.
when our theme is working no changes appeared,
when enabling batrick theme the added code was working.
This happens only in the page itself, i.e. when entering to localhost/drupal/node...
in the front page the added code worked for both themes.
any ideas?
tnx

wordpress. error creating content for custom templates with twentytwelve theme

i'm using the twentytwelve theme and i have to write custom content into my example template.
I want to maintain my header content so the main structure is the following
header = id page, wrapper
ex.page = primary, content
footer = close wrapper, close id page
If i have understood correctly, if i want to insert content into the middle of my page i have to do it into my template page (that is a copy of the main page.php), that is in the middle between my header and my footer
For example i want to insert a div into which insert the loop of such category.
The problem is that it displays me nothing, like i've wrote nothing. I can only see the contents if i erase all the originary div, but it's not what i want to do, just because the only div is the page which is my container.
I can't catch what i have to do.
Can you tell me what i forgot to do?
Thanks,
Alex
page.php is a "master" document. header.php, footer.php and (if it exists) sidebar.php are all imported into page.php. Twenty Twelve also uses atomized content templates. You may need to add your div to content-page.php, which is also imported into page.php. content-page.php is used inside the wordpress loop, and encapsulates the code that pulls in the actual article elements from the wordpress database.
If you are trying to add straight HTML to the templates, ensure that you are not adding code between the php brackets:
<?php // don't add html here ?>
<div>do add html here</div>
Depending upon the type of wordpress page you are trying to display, you may need to consult the Wordpress Template hierarchy to determine the proper Wordpress naming convention for your template file (the copy of page.php).
Technically speaking, everything in content-page.php can be put into page.php replacing the get_template_part function. All the 'content' pages are totally not required and can be combined into one file if you want simplicity.
In my opinion, it's easier to start from scratch when learning Wordpress rather than try and re-work something. The default wordpress themes don't lend themselves to be beginner friendly.

Adding A Button Between post-content and Related Posts Thumbnail Plugin on WordPress

I am trying to add a button to my WordPress template. Basically, I have the post and then there is the Related Posts Thumbnails widget that appears. I want the button to go between the text of the post and the related posts thumbnail widget. The code in my 'Single Post' that contains all of this is as follows:
<div class="post-content">
<?php the_content(__('<em><strong>More:</strong> Read the rest of this entry...</em>', 'life-is-simple')); ?>
</div>
I know the Related Posts Thumbnails plugin falls within this code because it's at that place when I 'Inspect Element' on Google Chrome. I can't find how to edit the order of things within that div though. Any help would be greatly appreciated, thanks!
EDIT
Clarification: I am using the Life Is Simple WordPress theme although it has been custom editing quite a bit (mostly on the CSS side of things though).
That plugin is probably appending the output to the_content with a filter .
That means , that the output is being added to the_content automatically. it is a common behaviour.
You need to look at the pluginĀ“s admin interface to see if you can have an alternative way (I believe there is ) which is using a template tag. in that case, you should put the template tag after the div where the the_content() is .
EDIT I :
After a small dig, - in fact there is - you need to put
<?php get_related_posts_thumbnails(); ?>
Then the plugin should know by itself not to append to the_content.
For parameter passing, or if something is not working, go read their APi or help files.
You'll probably need to edit single.php or archive.php in your theme. If nothing is occuring there that looks familiar, it's probably using a loop. In which case you might find what you are looking for either in loop.php, loop-single.php, or loop-archive.php depending on what type of page you are on and how the theme was constructed. Add your button near where you find Read the rest of this entry...
With more information (such as what theme you are using), one might be able to help more as well.

Resources