I have a RocketTheme Affinity template that when it hides the component the wrapper stays untouched and i want it removed also.
I only want to disable it from the home page (id=101).
In the "index.php" the bellow code calls this:
<?php
echo $section_rows->render();
?>
The div name is "section-row3" in a file called "rt_sectionrows.php"
There are also css files called style6 and tempate.css files.
Conclusion:
How do I hide certain div and class from homepage?
Try this,
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
?>
<script type="text/javascript">jQuery(document).ready(function(){
jQuery('.section-row3').hide()
});</script>
<?php
}
?>
Add this code at the bottom of your home page. It hide that div.
Hope it helps.
You should be able to just do this with some CSS.
Go into the Joomla! Administrator, Menus, Select the menu which contains your homepage menu item and then edit it.
In the menu item, select 'Page Display'. At the bottom you will see: Page Class.
Add a space and type: homep
Then add:
.homep .section-row3 {display: none !important;}
To your Rocket Theme Custom CSS or LESS file.
Then that will just hide it with CSS, we have specified !important, so it takes priority.
Related
I have a menu that is used throughout the entire site (pages and posts). I would like to change the link of one single menu item (custom link) if the menu is displayed on on a blog post.
I tried using the plugin Conditional Menus which could do the job, but has the disadvantage that I would need to recreate the entire menu for each language and repeat this everytime the menu is updated.
I think it would be smarter to do this through php. I found this to check post vs. page:
<?php
if(get_post_type() === 'post') {
// Do something
}
?>
Would it be possible to set the href of the <a> tag in menu-item-123 within this if-statement? Also, is there a way I can add this to functions.php in the child theme or does it need to placed somewhere else? Thanks!
Please write following codes in your functions.php file Here ".primary-menu" WILL BE the css class of your menu UL, I've setup 3rd child in the menu item, you can change it accordingly.
<?php
add_action( 'wp_footer', 'change_link' );
function change_link(){
if(get_post_type() === 'post') { ?>
<script>
(function($) {
jQuery('.primary-menu li:nth-child(3) a').attr("href", "https://google.com");
})(jQuery);
</script>
<?php }
}
In my Wordpress Theme, I have a "default" footer I use for every page, but I created a new footer I want to display only on the home page.
How do I hide the old footer and display my new footer on the home page?
There are a number of ways you could solve this, and none are more or less correct than the others. The way I would suggest is this;
Assuming you don't have it already, create front-page.php template and copy the content of page.php into it (if that's the template you're using).
Replace get_footer() at the end of front-page.php with get_footer('home') (assuming your new footer is called 'home-footer.php' (see the docs for more on that one)
As an alternatively, you could simply edit page.php and replace get_footer() with something like:
if(is_front_page()) { //check if current page is the home page
get_footer('home');
} else {
get_footer();
}
Which utilises the is_front_page conditional. (see conditional tags)
Open the header.php
Edit the <body> tag and make it <body <?php body_class(); ?>>
now in your homepage your body tag will render <body class="home">
then write css like:
body.home footer {
display: none;
}
add new footer in your homepage content
You can create custom template for homepage and call the new footer from that template using the function get_footer( $name ), here $name is the name of the new footer that you have created. Then select the homepage template from dashboard home page.
I am trying to hide the header on a specific page in WordPress. I know that I can do this using CSS.
The page id as displayed in the dashboard is:
wp-admin/post.php?post=31221&action=edit
The page has a header without an id or class (not sure who built it). But I can hide the header with:
header {display: none;}
I can't seem to hide the header on the specific page. I have tried:
.page-id-31221 header {display:none;}
.pageid-31221 header {display:none;}
I have also tried the same with # and postid etc etc. Is there another way to hide the header on that page?
Failing that is there a way I can hide the header after it has been called in the template? I have created a custom template for the page but im not sure of the php to use to hide it. If I remove <?php get_header();?> from the template then the whole page disapears.
The website is here: Website
You say you have created a template for this specific page.
In which case you can use jQuery to hide the header. Add this to the end (or start) of your page template.
<script>jQuery('header').hide();</script>
You would probably want to wrap this inside something like a jQuery( document ).ready(function() { to ensure the page is loaded before the script is run. Maybe add in the defer attribute too.
You can modify your header.php by adding an IF-statement which checks for the required pages by either the page/post ID or title.
Page/Post ID method:
if(is_page(get_the_ID()) != YOUR_PAGE_ID) { // show header }
Page/Post Title method:
if(!is_page(get_the_ID('PAGE_POST_TITLE'))) { // show header }
Either of these methods should work. *Not tested.
You can do this by checking the page name.
if( is_page( array( 'about-us', 'contact', 'management' ) ){ #hide your header; }
If you want more details please read the wordpress official documentation. It will helpful for you.
Read wordpress official documentation
This works for me. A simple trick:
Check your style class name in your header.php in the top example: class="header">
And place this code in the top from your php template or page.
<head>
<style>
.header { display: none; }
</style>
</head>
<body>
I have a menu but I'm including it on every page because I don't have to copy and paste the whole code on every page. So I'm including it by this way
require "menu.php";
This is what menu.php contains
Home
.....
News
And I want when I'm on Index page the background of the link in the menubar to be gray for example and not just for the index.php but for every other page. I know how to do it when I'm not including it, just add class and I stylize the class. But now I can't think how it could happen.
I would be appreciated if someone help me.
Thank you in advance
The way I would do it would be to add a class to your main <body> (or other parent container) tag that indicates the current page:
<body class='page-home'>
Then add classes to every single menu item:
Home
.....
News
Now you can write CSS styles that target your menu links differently depending on the current page:
.page-home .nav-home {
/** styles for the home link when you are on the homepage **/
}
Now you're handling all your styling in pure CSS, and it doesn't matter that your menu is an include. It's just up to you now to decide how much styling you want to do based on the current page and the specific menu links.
You can use this tricks:
get your file by file_get_contents() and replace your class name according to your file name.
In your menu.php file:
return
'<a class=[+index] href="index.php">Home</a>
.....
<a class=[+news] href="news.php">News</a>';
In your index.php
$strMenu = file_get_contents("menu.php");
$strMenu = str_replace('[+index]','is-active',$strMenu);
echo $strMenu;
In your news.php
$strMenu = file_get_contents("menu.php");
$strMenu = str_replace('[+news]','is-active',$strMenu);
echo $strMenu;
I am running Joomla and seeking you help for the following issue.
Lets say I have 3 layouts in my template and the layout files are named as...
index.php
index2.php
index3.php
I have 5 menu links say....
Link 1
Link 2
Link 3
Link 4
Link 5
What I am looking for is......
For Link 1, Link 4 and Link 5, I want Joomla to load the regular index.php but for Link 2 I want Joomla to load index2.php and similarly for Link 3 I want it to load index3.php.
What I mean is... How can we assign a different layouts to different menu IDs?
I know there is an inbuilt option to choose a different Template based on menu ID but I do not want to duplicate the template files just for this one function. Everything in my templates is the same just the change is in the layout depending on the Menu ID.
Kindly Help.
Are you using a commercial template or something custom? You should be able to code your index.php so that the layout is determined by the modules loaded on the page. You then control what modules show up by the menu assignments in the module parameters. You can control the layout being displayed through CSS, Page Class Suffix, and the code on index.php.
Every module position in your template should be collapsible - meaning that if no modules are loaded to the position, it does not get added to the HTML. Use something like this:
<?php if ($this->countModules('left')) : ?>
<jdoc:include type="modules" name="left" style="xhtml" />
<?php endif; ?>
You can also use a combination of the Page Class Suffix that you can set on the System Parameters of a menu item and CSS to control the layout of the page. I add the Page Class Suffix to the BODY tag of my templates so I can control every page individually.
First, you need to figure out which menu item you are on:
<?php
$menu = &JSite::getMenu();
$active = $menu->getActive();
if (is_object( $active )) :
$params = new JParameter( $active->params );
$pageclass = $params->get( 'pageclass_sfx' );
endif;
?>
Then you need to add that to the BODY tag as an ID:
<body id="<?php echo $pageclass ? $pageclass : 'default'; ?>">
Now you can use module positions and CSS to control every page. You can achieve vastly different layouts without having to go back in and touch code.
I always use include_once or for security purpose require_once, from my point of view it is a better way of programming in the template process.
- What do you think ?
- Example I would do this way :
(isset($_GET['Itemid']))?$itemID=$_GET['Itemid']:"";
OU POUR LES PURISTES DE JOOMLA :
$itemID=JRequest::getInt('Itemid',0);
if($itemID == '57')
{
require_once ("index1.php");
}
if($itemID == '58')
{
require_once ("index2.php");
}
else
{
// template code of index.php
}
On the basis of your menu ID (ItemID) you can include a different index<x>.php in your main index.php, like so:
$itemID = $_GET['ItemID'];
if($itemID == '57')
{
include index1.php
}
if($itemID == '58')
{
include index2.php
}
else
{
// template code of index.php
}