I am working on this website. I am trying to filter the the two arrows shown above each image(previous and next) if its the front page. I have created the following hook for it,
function removal() {
return null;
}
if(is_front_page()){
add_filter('prev', 'removal');
add_filter('next', 'removal');
}
The problem is that the images are still getting displayed. Any ideas why?
Edit: there is a more elegant way in the CSS style-sheet, taking advantage of the fact that WP gives the home page's body the home class:
body.home .prev,
body.home .next { display: none }
this targets the "prev" and "next" buttons on the home page only.
Old answer: Output the CSS in your if(is_front_page()) call.
In the page's <head> section, do
<?
if(is_front_page())
echo "<style type='text/css'>.prev, .next { display: none }</style>";
?>
Related
I was given the task of customizing a specific section of a website. This section is primarily made by an Event Manager Plugin on WordPress. This plugin allows users to create their own events that will be published in a calendar page. The thing is, I need to get rid of the page header only on the pages created by this plugin, that will have an URL similar to this: http://mypage.com/eventos/user-event-name
So, I only need to apply the code .site-header { display: none; } ONLY to the pages that have this /eventos/something URL. Can this be done?
When I put the above code on the Custom CSS of my theme it gets rid of the header across the whole website, and I don't want that.
I have absolutely no background in CSS so I most definitely am using the wrong definitions here. Thanks in advance, hope someone can help me!
You can check if there is evestos in URL and add a class to body
like this
add_filter( 'body_class','my_body_classes' );
function my_body_classes( $classes ) {
$url = strpos($_SERVER['REQUEST_URI'];
if($url, "/eventos/")) {
$classes[] = 'eventos-page';
return $classes;
}
}
After that you can add css to that class like for example
.eventos-page .site-header {
display: none;
}
I am trying to style the error page related to the error "This has been disabled".
This error comes up when people try to access the page https://benefacto.org/wp-admin/.
I thought maybe because it was a link with "wp-admin" it might be related to back-end styling?
I tried styling it with my stylesheet that is enqueued on the back-end it did not work.
Is there maybe a specific stylesheet I need to enqueue to style the error?
This is the styling I am trying to apply to the page:
/* Customises the WP-Error message on the login page */
body#error-page {
background: #9100c0 !important;
}
Here is a screenshot of the page I want to style:
The link for this page is "example.com/wp-admin"
I appreciate any help or suggestions! ^_^
This one login page for update css. Error page for not any filter functions more information
Add this code on your activated theme's function.php
function my_login_custom_css() {
?>
<style type="text/css">
body#error-page{
background-color: #9100c0;
}
</style>
<?php }
add_action( 'login_enqueue_scripts', 'my_login_custom_css' );
I found this one Remove breadcrumbs if "home" in wordpress
but sadly not working for me
<body<?php if(! is_home()) echo ' id="homepage"';?>>
in header.php
body#homepage#breadcrumbs {visibility: hidden;}
and added in style.css
First change your css to this. Because Breadcrumb Trail uses a class of breadcrumbs and not an id.
body#homepage .breadcrumbs
Have you tried using is_frontpage() instead of is_home() ?
Do you realize that at the moment you are adding homepage id to all pages which are not the "home" page? Don't use the ! in your if.
<body<?php if(is_frontpage()) echo ' id="homepage"';?>>
blog postspage = frontpage
On the site front page:
is_front_page() will return TRUE
is_home() will return TRUE
static page = frontpage
On the page assigned to display the site front page:
is_front_page() will return TRUE
is_home() will return FALSE
On the page assigned to display the blog posts index:
is_front_page() will return FALSE
is_home() will return TRUE
Try separating the #breadcrumbs.
In the CSS:
body#homepage #breadcrumbs {visibility: hidden;}
The code you posted refers to a body element with an ID breadcrumbs. What you need to target is an element with #breadcrumbs ID, that is inside a body with #homepage ID.
Also, the body has .home class in Wordpress by default.
So you can achieve it without the PHP part.
body.home #breadcrumbs{display:none;}
There is another way to do it using body_class()
<body <?php body_class(); ?>>
And then in the css if it's home page you can use
body.home #breadcrumbs { visibility: hidden; }
You can either use the if condition with home page id.
CSS Update - it's .breadcrumbs not #breadcrumbs:
body#homepage .breadcrumbs { visibility: hidden; }
PHP:
<body<?php if(is_home()) echo ' id="homepage"';?>>
In your header.php code, the ! means NOT, therefore you're saying:
if NOT homepage, add id "homepage"
Which is the opposite of what you want.
Also note that visibility:hidden will hide the element but preserve its space in the layout.. if you want to hide the element and its space you can use display:none instead.
As #Eric-Mitijans explained, you have to add a space between body#homepage and #breadcrumbs otherwise you'd target a body tag with 2 IDs which is incorrect syntax.
So I have a dropdown menu which contains a login form. This comes from aWP plugin so I can't edit the code directly. Now once I enable said plugin it always shows on the website. I only want it to show if is_user_logged_in is false. The solution I came up with would be to use an if statement to check if the user is logged in or not and to show some text or the login form depending on the situation. Now this idea didn't work since the login form will always show. My question therefor would be if its possible to add some css to a class when I don't have access to the HTML? The code I came up with so far is noted below.
<?php
if ( is_user_logged_in() ) {
/* The logout function */
} else {
/* The code that SHOULD change the CSS. */
}
?>
Now obviously I removed the logout function since it's not needed here and it makes the code look cleaner.
PS. The class we need to change would be .lorem and the styling would be display: block/none;
Change the .loginForm to your class or id of your loginf form.
add_action('wp_head', 'my_function');
function my_function() {
if (!is_user_logged_in()) {
?>
<style>
.loginForm {display: none}
</style>
<?php
}
}
I want to hide the top slider part from the blog pages but in the first blog page I want to keep it. You can check this link: http://site4preview.site90.net/wordpress/ . There are two pages in the page navigation. I want to hide the slider from all pages starting from the page number 2 except 1. So is there any way to do it please ? Thanks in advance.
You need to check if that page is a "pagination" page, for this you must use is_paged().
Try this.
<?php
if( !is_paged() ) {
//Slider Goes Here
}
?>
EDIT:
You could just hide with CSS, it's not the best solution, but it get the job done.
If you have multiple sliders you could use this cascade to be more precise
.paged .block-content .widget-area .recent-posts-flexslider-class {
display: none
}
just hide all sliders under the paged pages
.paged .recent-posts-flexslider-class {
display: none;
}
or, if you know CSS hide the div you want utilizing the class .paged that shows only when you're visualizing a paged template