How to Change logo on the specific page of website in wordpress? - css

I m working on a website in wordpress.
I searched for a problem that i want a different logo in one page of my site using any plugin but i didn't find a satisfactory solution.
Kindly someone tell me how can i do this that main logo should be appear on the whole site but secondary logo should appear on one page of my site

if you know wordpress developement, you can use conditional tags. ref

You can use the is_page() method to check which page you are in and change the logo accordingly.
So, in the header or where ever your logo is displayed, you will do it like this:
<?php
//Returns true when the Pages displayed is either post ID = 42, or post_name is "about-me", or post_title is "About Me And Joe".
if(is_page( array( 42, 'about-me', 'About Me And Joe' ) ) )
{
//display the secondary logo
}
else
{
//display the main logo
}
Of course I'm assuming here that the page you want it to be different is a WordPress page
If it's a listing page or a single post page then you can use different methods of checking. All of which are described here.

Please insert this code to your header.php file.
$ss = $wp_query->post->post_title;
if($ss == 'your page name'){
echo '<img src="/your-new-logo.png" />';
}
else{
echo '<img src="/your-current-logo.png" />';
}

Related

How to display featured image of HOVERED wordpress post in a specific DIV?

I want to make my websites first page so you have posts listed with only titles and meta.
When you found something interesting you'd put the cursor on the title (linking to the post) and that would display a featured image beside (either on a specific spot on the site or offset just enough to not cover any of the text or replacing the cursor).
Here is an example in action:
example of hover effect
I would put this code in a PHP snippet that I would add to a page with a shortcode. Right now the best I have is this:
<?php
echo '<div class="feauturedImg">';
$args = array('page_id => );
$featured_image = get_posts($args);
foreach($featured_image as $image) : setup_postdata($image);
echo the_post_thumbnail();
endforeach;
wp_reset_postdata();
echo '</div>';
?>
It should make a div and display the featured image inside it. I need to get the featured image of whichever post is being hovered dynamically. This is how I'd get the link of a hovered post in JS but I don't know how or if it's even possible to implement it.
I would need to pass it in to the PHP and get the post ID from it:
<script>
$('.hoverLink').hover(
function(){
var myHref = $(this).attr('href');
},
function(){
$('.hoverDetail').remove();
});
</script>)
Basically I need a way to get the hovered link from a JS or a way to save a hovered link into a PHP variable to than put it in url_to_postid() function and get the ID of the post to put into this section:
$args = array('page_id => );
(first PHP code) to display the right image.
Any ideas?

How to add page URL to list of pages in WordPress admin panel?

Currently, by default, the following columns appear in the list of pages in the WordPress admin panel:
Title
Author
Comments
Date
and because I have AIO SEO installed:
SEO Title
SEO Description
SEO Keywords
Is there a way to have WordPress also display the URL to the page (at least the part of the URL that is created when the page itself is created)?
The page url is actually already there by default, it's just hiding. When you hover over a page title, several links appear below the title -- edit, quick edit, trash, view. View is the hyperlink to the page, which you can click to view the page, or right click and copy the link address to use elsewhere.
Otherwise, if you are using a custom/child theme, you could add the following to your functions.php file:
add_filter('manage_page_posts_columns', 'my_custom_column', 10);
add_action('manage_page_posts_custom_column', 'add_my_custom_column', 10, 2);
function my_custom_column($defaults) {
$defaults['url'] = 'URL';
return $defaults;
}
function add_my_custom_column($column_name, $post_id) {
if ($column_name == 'url') {
echo get_permalink( $post_id );
}
}
Note: This just creates a text url to your page.
Also note, you do not want to edit your functions.php file directly if you are using a theme you did not create, as it will be overwritten when you update. If you want to add this to an existing theme, I'd suggest looking into child themes.
This is helpful. I would only improve the output slightly by removing the site url and just showing the page. Takes up less space and less to weed through visually.
if ($column_name == 'url') {
$siteURL=get_site_url($post_id);
$link= get_permalink( $post_id );
echo str_replace($siteURL,"",$link);
}

how to create multiple shortcodes in Wordpress and selectively position them anywhere in a custom template page file

In my functions file I have this:
function caption_shortcode( $atts, $content = null ) {
return '<span class="caption">' . $content . '</span>';
}
add_shortcode( 'caption', 'caption_shortcode' );
In the CMS page editor I have this:
[caption]My Caption[/caption]
This page is utilizing a custom template file template-mypage.php. My question is: I would like to create multiple short codes types within the CMS such as:
[caption1]My Caption[/caption1]
[caption2]My Caption[/caption2]
[caption3]My Caption[/caption3]
then in my template-mypage.php... I would like to selectively choose where to place [caption1], [caption2], [caption3]... for example [caption1] will go somewhere on the top... [caption2] in the middle and [caption3] towards the bottom of the template-mypage.php, all seperated by some huge chunks of HTML content. I do not want to write any HTML within the WP CMS... all HTML should be written in the template-mypage.php.
Currently I believe WP limits shortcode output to come out of the_content(); Is it possible to do something like the_content_of_caption1(), the_content_of_caption2(), the_content_of_caption3()?
Thanks please let me know!
this product does this perfectly
http://wordpress.org/plugins/multiple-content-blocks/

WordPress page child

I would like to display an image based on the page ID.
The issue I am having is with child pages. I would like to have a method for identifying if the current page is a child of a certian page no matter how many levels deep.
Example.
Home -> Programs -> Baseball
If Programs or Baseball or anything below baseball, display image X
Else
Image Y
Take a look at the parent/child functions available in the Wordpress Codex such as : http://codex.wordpress.org/Function_Reference/get_post_ancestors
get_post_ancestors seems like your best bet, from there you can impart what ever logic you may need to select and (dis)quality results in your script.
There are other selection tools in the codex that might do better.
<?php
if ($post->post_parent == '100') { // if current page is child of page with page ID 100
// show image X
} else {
// show image y
}
?>
Or:
<?php
$anc = get_post_ancestors( $post->ID );
if (in_array("100", $anc )) {
// show image X
} else {
// show image y
}
?>

How to Show Custom Post on different Single.php File in wordpress?

i have created a Custom Post type Movie, and Also created a page Movies and Showed all the movies on that page. Great….
“But the Problem is”, When I click on that movie, Its’ going on the same single.php page, and that’s what I don’t want, I want a Saprate Single.php file for this movie section and seprate others like news, videos, so tell what i’ll do for this
Create single-movie.php file in your theme. Put custom code in there.
For any other custom post type use single-{custom-post-type-slug}.php
heres how to do it.
Delete everything in your single.php insert the following, and create multiple single.php files for your needs.
[note: in_category('id of your category')
<?php
$post = $wp_query->post;
if ( in_category(‘3′) ) {
include(TEMPLATEPATH . ‘/single-photo.php’);
} elseif ( in_category(‘4′) ) {
include(TEMPLATEPATH . ‘/single-video.php’);
} else {
include(TEMPLATEPATH . ‘/single-default.php’);
}
?>
Good luck ^ ^

Resources