I have setup Multiple featured image plugin. That's work good for me.
My requirement is:
if: The Multiple Post Thumbnail Exists
then: Show the Multiple Post Thumbnail Image
else: Show the Default Featured Image Thumbnail
Right now i have displayed multiple featured image using following code:
<?php add_image_size('post-big-artful-interiorsimg-fullsize', full);
if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'big-artful-interiors', NULL, 'post-big-artful-interiorsimg-fullsize');
endif;
?>
and default featured image display using following code:
<?php the_post_thumbnail('thevoux-single',array('itemprop'=>'image')); ?>
How can I show default featured image if Multiple featured image is not available. Any idea then inform me.
Try This code
<?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('post', 'big-artful-interiors')) {
add_image_size('post-big-artful-interiorsimg-fullsize', full);
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'big-artful-interiors', NULL, 'post-big-artful-interiorsimg-fullsize');
} else {
the_post_thumbnail('thevoux-single',array('itemprop'=>'image'));
} ?>
Related
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?
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" />';
}
I am new to wordpress. I have started creating custom theme. I am getting my content via following method:
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
the_content()
//
} // end while
} // end if
?>
I added lot of images on my website. These images are automatically sizing from wordpress. I want to add hyperlink (link of same image) to all images in a post. But I don't want to do this manually one by one.
Following is example of what I want to achieve:
<img src="sample.img" />
//to convert
<a href="sample.img" class="mycustomclass">
// Image link:
<img src="sample.img">
</a>
Follow These steps to link an image in Wordpress WYSIWYG editor.
https://en.support.wordpress.com/links/image-links/
I have implemented my blog using wordpress and in my posts iam directly posts the images but while if I want to display them they are not retrieving.
I have used the_content() then it was displaying the image with the remaining content in that post can anyone suggest me How to retrieve those images..??Thanx in advance
You are inserting images in the content area,so obviously it will be appearing as content on front end.
You need to set the images as Featured image or add them by using Add media option at the top of text editor.
For retrieving the image from Featured image:(Single image)
wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full')
For retrieving the image from Add media:(Multiple images)
$img_small = get_children('order=ASC&orderby=menu_order&post_type=attachment&post_parent=' . $post->ID);
foreach ($img_small as $imagesmall) {
$attachmentID = $imagesmall->ID;
$attachmentURL = wp_get_attachment_url($attachmentID);
<img src="<?php bloginfo('template_url'); ?>/phpThumb/phpThumb.php?src=<?php echo $attachmentURL; ?>&w=365&h=280&iar=1">alt="Image" />
}
I have a view that pulls in the titles from 3 different content types. One of these content types has a title that should link to an external website, the other 2 types have titles that link to nodes within the Drupal site. Is there a way I can set the Title field to handle links differently depending on what content type the title is from?
Answered thanks to Vlad below!! :)
This is the working code we are using in the views-view-fields--news--block.tpl.php template..
<?php if ($fields['type']->content == 'Event'): ?>
<?php print $fields['title']->content; ?>
<?php endif; ?>
<?php if ($fields['type']->content == 'PATF News'): ?>
<?php print $fields['title']->content; ?>
<?php endif; ?>
<?php if ($fields['type']->content == 'News Link'): ?>
//This link goes to _blank
<?php print $fields['title']->content; ?>
<?php endif; ?>
Drupal 6
In your view settings, add Node: Type to Fields
In Basic settings group click Theme: Information and click Row style output
Copy all content from Row style output into your theme file (should be named something like views-view-fields--viewsname.tpl.php or views-view-fields--viewsname--viewsnamw.tpl.php) in your theme folder.
Modify output where you should check content type and make different output.
Drupal 7
It's pretty similar with difference that you can find Theme: Information in group Advanced and you have to add Content: Type in your Fields group.
In your views-view-fields--xxx--xxx.tpl.php file write something like:
if ($fields['type']->content == 'Page') {
// print title linking to node
print $fields['title']->content;
}
if ($fields['type']->content == 'News') {
// print title linking to other website
print 'http://example.com/'. $fields['title']->content;
}
Improved code
$link = $fields['path']->content;
$title = $fields['title']->content;
$options = array();
if ($fields['type']->content == 'News Link') {
$link = $fields['field_link']->content;
$options['attributes']['target'] = '_blank';
}
print l($title, $link, $options);
I've done this before with the following steps:
Include fields for Content Title, Content Link, and your external
Link.
Hide Content Title and Content Link from view.
Rewrite results for Content Link should be set to the token for
Content Title (both still hidden).
No results behavior for you external link field should be set to the
token for Content Link.
This displays the external link whenever it's present, and will fall back to a the title linked to the original piece of content whenever it's not.