How to remove Wordpress taxonomy description from paged pages - php

I'm attempting to remove or prevent the from being added to is_paged() taxonomy pages (tag and category pages).
I'm not sure if it is possible to remove, however is it possible to set a condition that this class is only added is the page is NOT is_paged(). This will prevent the class="clr tax-desc" from being displayed on page 2, page 3, page 4, etc of my category and tag pages.
I only want the class="clr tax-desc" to be present on the main page (or page 1) of the relevant category and tag pages.
I need to create something along the lines of:
if ( is_archive() && !is_paged()) {
Remove <div class="clr tax-desc"></div>
}
Any suggestions on how to go about this?

If not mistaken, does the description under the category name have the class entry-meta?
If you give this class in your css the property
display:none;
then it will be hidden from your pages.
So add this line into your css and it should be gone.
.entry-meta { display:none; }

Related

Remove page headers without removing post headers

Using WordPress. My header navigation includes pages that link to categories. For instance, the 'about' in the header navigation is a page but it links to a category called 'about'. On this page, I have the page title displaying and then the post with the 'about' category is also displayed on this page.
When I try to remove the page title ('About') it removes that title AND the post's title on that page.
Ex. I am able to modify the pages with: (.category-21 is the ID for the about page)
.category-21,
.category-22,
.category-23 {
color: blue;
}
But when I try to remove the page title with:
.category-21 h2,
.category-22 h2,
.category-23 h2 {
display: none;
}
It removes the page title AND the post's title.
The problem is that the header 2 modifies both titles.
How do I separate the two?
What would I add/modify to functions.php (or single.php?) and to style.css?
I'm also using this to exclude posts with the category of 'about' (and two others):
function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '-21, -22, -23');
}
return $query;
}
add_filter('pre_get_posts', 'excludeCat');
I think it's also excluding these categories from certain style changes in style.css (if that helps).
.category-23 h2:nth-child(2)
OR
.category-23 h2:last-child
OR
Add a class to another h2 and then change the style of it.

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.

Is there a conditional in Wordpress for a specific tag page?

I want to change the meta description on my Wordpress website for a certain page that queries all the posts containing a certain tag.
The page I am talking about looks like this:
mainwebsite.com/tag/tag-name
So I want to add in the header.php file a conditional where I can change the meta description only on that page. I tried the following:
<?php if(has_tag('this-is-the-tag-name')){
echo 'test';
}
?>
And this puts "test" on every single tag page. I want the change to apply only on the tag page "this-is-the-tag-name."
Say your tag name is "slug". Look at the template hierarchy for tags. Wordpress will start from the top, and work its way down until it finds an available template to display the tag
tag-slug.php > tag-id.php > tag.php > archive.php > index.php
With that said, if you create a template called tag-slug.php, you can simply add a if( is_page_template( 'tag-slug.php' )) statement to your header or functions.php, and your conditions will only display on that specific page.

How can I hide top slider from the remaining blog pages except the first blog page?

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

how to show a element only in post page wordpress

There is a div element in header.php which I want to show only in post page.
The div should not be visible on home page or 404 page or category or pages or tag page.
It should be only visible post page.
The method I am thinking is using css. The div element will have a class. Let the class be hide-container this class is set to display:none;. . the trick is show another div container in post page.
Like this below code which shows the class in singles.
<div class="hide-container <?php if(is_singular() ) { ?>container<?php } ?>">
The above code will have worked, but it shows the div element on all pages except home page. I only want the div to be displayed in post page.
thanks in advance.
use the is_home() conditional tag
<div class="social-tools <?php if(is_home() ) { ?>container<?php } ?>">
even though its written like that - is_home() shows the posts page
check out this question

Categories