How to set slider only on Homepage in Drupal 7.31? - php

I set my slider only on Homepage with tag in Drupal 7.31 but it black div is taking same div space on other page but slider is not coming. Help me.
I'm using "Bartik" theme.

If you want to display specific content on your drupal homepage than add following code in your page.tpl.php file or you can do it using create Block region position.
<?php
if (drupal_is_front_page()) {
// your slider code goes here
}
?>

If your content is a block, go in the settings of your block and choose the option : display only on listed pages, in listed page add the value <front>

Related

How to add plugins to my custom wordpress theme?

I'm making a WordPress theme by myself since I'm working for the first time in Wordpress I've watched some tutorials about it.
I have page.php header and footer and ofc an index. I insert the content from the pages with this:
<?php echo get_post_field('post_content', $post->ID); ?>
but I tried the get_post in a while loop with same result..
Everything is fine but when I want to use a plugin I can't add to my page... When I insert the shortcode of it it shows only the shortcode string... There are some plugins where I can click a "view" option and it would show a page with my plugin (for example a calendar) but that page is empty...
When I activate an original theme it works instantly... So I'm sure something is missing from my theme something which can load the plugins but I couldn't find solution for it.
Any ideas?
Did you add the <?php wp_head(); ?> function before the head area of the html document is closing? It imports important scripts and styles from wordpress itself (and probably also from the plugins).
See here:
https://developer.wordpress.org/reference/functions/wp_head/
Before closing the body area, the template should also include
<?php wp_footer();?>
See here:
https://developer.wordpress.org/reference/functions/wp_footer/

Convert html to wordpress & provide link to menu inside panel

I have an HTML template which I am trying to convert into PHP for WordPress.
The homepage has been converted and is shown properly. Next, the menu in navbar is about, the page that needs to be converted in PHP.
I have just added get_header() at the top and get_footer() below. In between these two I have added the HTML content for my entire page.
Then I tried to provide the link for the menu that I created, but the content of about page is not visible.
Do I need to add any other line for that page apart from get_header and get_footer? Or is something wrong with the link?
Clearly I can't understand what your are trying to say. I think you want to create a page that will show your about menu content.
So in your theme directory create a page name page.php and use get_header(); in first and below get_footer and where you want to show page content write the_content();. like this
<?php
get_header(); ?>
<div><?php the_content(); ?></div>
<?php get_footer(); ?>
after that follow the url of # Sajid Anwar. because for dynamic data you have to create pages(home,about etc) from wordpress dashboard and in menu section add these pages as navigation menu to menu.

Visual composer Masonry grid doesn't load

I'm using [insert_php] plugin in Wordpress and I have inserted php function in it.If I set the block with the function before the the masonry grid it doesn't load.
If I move the block with the function after the grid it works well.
In console log is appearing an alert:
Syntax error, unrecognized expression: {'status':'Nothing found'}
How can I sole that?
Grid before php block
Block php before the grid
What you need to do is create a page template. This page template can be used to create PHP for your page to load, and you can even use
<?php echo do_shortcode('[shortcode]'); ?>
To create a template just copy your page.php into a new file called tpl_test.php.
Then make sure to have this in the very first line:
`<?php
/*
Template Name: Test Template
*/
?>`
Then, a small window will show up on the back-end of WordPress when you edit the page. In the right hand column you need to select the page template for the page you just created, and update the page. then, any code you put in the custom Page Template will display correctly on your WordPress site. Also, make sure <?php the_content() ?> is below your grid you are trying to output.

wordpress link home page to different page

I have created html pages and trying to convert into wordpress theme,how to link html one page to other page in wordpress menu bar
sample code :
Features
this code is not working,it 's showing page not found.how to make this link in wordpress using php code.
Firstly Create Page "Features" from wp-admin.
Create template for this page.
http://codex.wordpress.org/Stepping_into_Templates
To set this page in menu Go in "Menu" section in WordPress.
http://codex.wordpress.org/Appearance_Menus_Screen
To view this menu in fronted use wp_nav_menu()
Take example template from your theme.
This is file in theme ending with -page.
Change template name in head of a file.
Then remember about the_loop all should be inside a loop to work correctly with many pages.
Put html there, also in header.php attach css to this html.
Page structure is like, header in the up, then page and then footer.
Remember to preserve good html structure - divs beginning and ending.
Then you create a page with content ( which is presented in the_loop ) , which has its own url address.
You can set url naming of pages in settings -> permalinks, you may need to write to .htaccess file.
Then you have direct url to page. You can use it in code like this:
echo bloginfo('url'). 'nameofpage';
All to do is create a template and assign it to page ( on page edit page template option ).
You can use pages or posts for this, i prefer pages.
Create new pages or posts and get their ID.
For linking its:
Get link with this:
get_permalink( $yourPostOrPageID ); // only get; not echo
Otherwise
Wordpress homepage link:
get_bloginfo('home');
Category or custom taxonomy term link:
get_term_link( $term, $taxonomy );

Conditionally display menu for page type in Wordpress

I am relatively unfamiliar with Wordpress and I am creating a custom theme for a client. I would like to either display or remove the main menu depending on the page type. I have researched several options like removing the navigation from header.php and referencing it separately and also making the menu conditional which is preferable.
I have a custom page type in my theme called 'landing page' on which I would like the menu to be never be displayed, though it will be on every other page. Ultimately there will be a lot of these and I would rather I didn't have to intervene.
I would rather not duplicate my header.php file but I can only find reference to displaying the menu conditionally like below by page name or ID which seems ridiculous.
<?php
if (is_page('contact')){
<?php include(TEMPLATEPATH.'/headerA.php'); ?>
}
elseif (is_page('gallery')){
<?php include(TEMPLATEPATH.'/headerB.php'); ?>
}
else {
<?php include(TEMPLATEPATH.'/headerA.php'); ?>
}
?>
Rather than including files as above, I will put the whole thing into my header and just make the navigation conditional. Does anyone know how I should approach this using my custom page type landing page rather than by page name so every page created with that type will never have a menu?
Thanks
Are you talking about a Custom Post Type (CPT) or a page called landing-page?
They are completely different. See http://codex.wordpress.org/Post_Types
In any event, this will work for a custom post type or a page:
if ( !is_singular( 'custom-post-type-name-or-page-slug-here' ) ) {
get_template_part('menu');
}
It says: "If this page is not a single page or a CPT, load the file menu.php from the theme folder."
See also http://codex.wordpress.org/Include_Tags:
The get_template_part() tag includes the file {slug}.php or
{slug}-{name}.php from your current theme's directory, a custom
Include Tags other than header, sidebar, footer.

Categories