I want to show home page title in breadcrumb. I have tried the get_the_title() function, but it requires page id as parameter. I believe it will break when I change the front page to other page.
Is there a function that is more change prone?
this is how I solved my problem
$home_title = get_the_title( get_option('page_on_front') );
that way, when I change home page with diferent page, the code won't break. It also works on multisite.
Please try this..
<?php echo bloginfo('title'); ?>
<?php echo bloginfo('title'); ?>
This will echo you title of your website given in settings.
Related
I'm developing a website whereby I would like customers to be able to constantly view the contents of their cart so they can add/remove items on the fly (using WooCommerce).
The theme I'm currently using is Flatsome (with the UXBuilder)
I've noticed there is a template for the WooCommerce mini-cart in woocommerce/templates/mini-cart.php. This looks like what I want to be displayed on my page
I have a plugin called WooCommerce Product Tables that (I believe) displays this mini-cart like this
I was wondering if there is any way for me to display this as a fixed element (within a div perhaps) on my page?
I'm quite inexperienced, so any help is appreciated :)
As Bhoomi suggested, using woocommerce_mini_cart(); works however ajax cart doesn't update the minit cart.
Using this method I suggest to wrap mini_cart function with "widget_shopping_cart_content" woocommerce class, for example :
<div class="widget_shopping_cart_content"><?php woocommerce_mini_cart(); ?></div>
So with ajax add to cart, the mini cart is updated also.
First Create the shortcode on function.php
// Add Shortcode
function custom_mini_cart() {
echo '<a href="#" class="dropdown-back" data-toggle="dropdown"> ';
echo '<i class="fa fa-shopping-cart" aria-hidden="true"></i>';
echo '<div class="basket-item-count" style="display: inline;">';
echo '<span class="cart-items-count count">';
echo WC()->cart->get_cart_contents_count();
echo '</span>';
echo '</div>';
echo '</a>';
echo '<ul class="dropdown-menu dropdown-menu-mini-cart">';
echo '<li> <div class="widget_shopping_cart_content">';
woocommerce_mini_cart();
echo '</div></li></ul>';
}
add_shortcode( '[custom-techno-mini-cart]', 'custom_mini_cart' );
Then add this [custom-techno-mini-cart] short code anywhere on page.
Now add this inside your template
<?php echo do_shortcode(['custom-techno-mini-cart']); ?>
Hope This will help you.
Make your layout according to your requirement in first point.
ADD Like This ALSo using This
woocommerce_mini_cart()
You can use woocommerce_mini_cart() wherever you want to display your minicart.
This function loads the mini-cart.php template to display the mini cart.
How to display author name near the date on my website homepage and single post page? . Is there is css code for that. Iam using hemingway theme. And my website is www.avjtrickz.com . please help me, Thanks for advance.
You have to use:
<?php $author = get_the_author(); ?>
or:
<?php the_author(); ?>
Here you can find more information: https://codex.wordpress.org/Function_Reference/get_the_author
And here: https://codex.wordpress.org/Function_Reference/the_author
And here: Show Author name in single.php (Wordpress)
This needs to be done using the WordPress codex for author. This reference needs to be used in the Loop. There is no CSS for this.
https://codex.wordpress.org/Function_Reference/the_author
<?php $name = get_the_author_meta( 'display_name' ); ?>
reference : https://developer.wordpress.org/reference/functions/get_the_author_meta/
Is there a way to get a thumbnail from any website link? For example, if I take a link from imgur and post it on my website in the post itself, it shows the image. But when I go to the homepage of my website there is no featured image for that post. Just a great box. How could I generate a featured image of any link I posted from an external website?
I have used the video thumbnail plugin but it only works with certain websites.
try going into page.php of your theme, then search for the_post_thmbnail(). There add the image link
change this line:
<?php the_post_thumbnail(); ?>
to something like this:
<?php $name = get_post_meta($post->ID, 'ExternalUrl', true);
if( $name ) { ?>
<?php the_post_thumbnail(); ?>
<?php } else {
the_post_thumbnail();
} ?>
hope this helps :)
I'm looking for a WordPress way to remove current and all grandparents from breadcrumbs. Basically, functionality is identical to history back button, but with page title. Don't want to do this in JS for obvious reasons.
Any ideas?
Cheers!
There is an easy solution to that, no need for breadcrumbs:
<?php if($post->post_parent) {
$parent_link = get_permalink($post->post_parent); ?>
Back to <?php echo get_the_title(wp_get_post_parent_id( $post_ID )); ?>
<?php }
I want to remove the featured image in post and page, but keep it as thumbnail so that the site look good! My site is a wordpress based site.
Here's an example post of the site: http://www.tradingspotsilver.com/build-mt4-custom-ea-indicator-forex-free/
You could see that the featured image is on top of the post and occupy a lot of space. I've tried to look at the theme source but no luck.
The link given in your question is a single post page, you look in to your theme's root folder and can find a file named single.php, in that file you may find something like this
// "custom_size" could be anything like "single_page_image"
if ( has_post_thumbnail() ) : the_post_thumbnail('custom_size');
This line of code is responsible for showing the big image. Just remove this line and your image will not show up. Also, you may check this answer for custom image sizing.
For page template, you may look for a file named page.php and look for the similar code.
you can use timthumb for resizing:
with the code here: { https://code.google.com/p/timthumb/source/browse/trunk/timthumb.php }
create a file named timthumb.php in your theme folder, and at the place of the featured image php script, type:
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
//the_post_thumbnail();
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<div class="img-hold"> <img src="<?php bloginfo('template_directory') ?>/timthumb.php?src=<?php echo $url; ?>&w=219&h=125" width="219" height="125" /></div>
<p><? }
echo $content;
?></p>
change the value of height and width as per your wish at &w=, &h= and also width= , height=
hope this helps
just remove the the_post_thumbnail code in the single.php and page.php or content.php.
this function use in wordpress for show featured so just remove or comment it.
check your single.php and content.php page to solve this problem its right there
if you dont require that code comment it / or modify it as you want.
dont mess things go easy with it or otherwise you will end up getting error
I had the same issue and i could not find any solution in single.php
Its simple although:
just comment:
from content.php page
This is for the Dazzle Theme
I found mine in "content-single.php and removed :
<?php the_post_thumbnail( 'dazzling-featured', array( 'class' => 'thumbnail' )); ?>
Picture was gone from post.
It is obviously varies depending on theme.
For theme Freemium you need to remove the following lines in wp-content/themes/freemium/single.php:
<?php $freemium_feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); if($freemium_feat_image!="") { ?>
<img src="<?php echo $freemium_feat_image; ?>" alt="Banner" class="img-responsive img-responsive-freemium" />
<?php } ?>