Show the summary in the title card - php

I want the summary to appear instead of the title when the card is hovered over.
That is, instead of:
<div class="cardpro-main" title="<?php the_title(); ?>" data-toggle="tooltip" data-placement="bottom">
I want to use the following code:
<div class="cardpro-main" title="<?php the_excerpt(); ?>" data-toggle="tooltip" data-placement="bottom">
When I use the code: title="<?php the_excerpt(); ?>"; The summary is displayed as: <p>summary</p>.
Is there a way to hide the <p></p> tag?

Please try this it will not show the p tag
<?php echo get_the_excerpt(); ?>
As per your requirement below is the full code.
<div class="cardpro-main" title="<?php echo get_the_excerpt(); ?>" data-toggle="tooltip" data-placement="bottom">

Related

WordPress Image not showing up when searching the website but title and article button do

I am trying to fix a fault in my website, when a user searches an article the title and button show but the article image does not, the image of the search result is below. The code below displays the title and the button, does anyone know how I can locate the code to get the image also?
(Below is the previous code) Code 1
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?
>"><?php the_title(); ?></a>
So the code to retrieve the images using PHP is:
<?php the_post_thumbnail(); ?>
(Displayed within the code)
<a id="featuredimg" href="<?php the_permalink(); ?>" title="<?php
the_title_attribute(); ?>"> <?php the_post_thumbnail(); ?><br> <?php the_title();
?> </a>

How can I change button text, depends on site slug (PHP, Wordpress)

First of all, I wanted to say that I know nothing about PHP (it is totally not my pair of shoes). I was asked to make something in Wordpress theme, that will translate text in the button, depends on site language. The difference is visible only in slug so I assume, that I have to somehow get info is slug contains "en" or "de" and pass that info to translate function.
Problem is, that I don't know where to start. I will appreciate any kind of help.
<div class="read-more clearfix">
<a class="button post-button" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php esc_html_e('Read more', 'astrid'); ?></a>
</div>
Put this code in functions.php file
if(strpos($_SERVER['REQUEST_URI'], 'de') !== false ){
//If your slug is de
_e('<div class="read-more clearfix">
<a class="button post-button" href="'.the_permalink().'" title="'. the_title().'">'.esc_html("Read more", "astrid").'</a>
</div>');
}
else{
//If your slug is en
_e('<div class="read-more clearfix">
<a class="button post-button" href="'.the_permalink().'" title="'.the_title().'">'.esc_html("Read more", "astrid").'</a>
</div>');
}
If you want to only replace a button text above code are good but if you want to set on all page use language based translation plugin.
I think it'll do the job.
function the_title(){
$language = $_GET["slug"];
$buttonText = "";
switch($language){
case "fr":
$buttonText = "Le texte de mon button";
break
case "de":
$buttonText = "Mein Schaltflächentext";
break
// etc
case default:
$buttonText = "My button text";
break
}
return $buttonText;
}
But if you want to translate more things you'll need to use language translation based plugin or create yours. Because otherwise it will quickly become difficult to maintain
<?php elseif(strpos($_SERVER['REQUEST_URI'], 'en') !== false ): ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div>
<div class="read-more clearfix">
<a class="button post-button" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php esc_html_e('Read more', 'astrid'); ?></a>
</div>
<?php else : ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div>
<div class="read-more clearfix">
<a class="button post-button" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php esc_html_e('Czytaj więcej', 'astrid'); ?></a>
</div>
<?php endif; ?>

How to add header H2 in PHP class

Im trying to obtain an H2 header for class "aawp-product__title"
<div class="aawp-product__content">
<a class="aawp-product__title" href="<?php echo $this->get_product_url(); ?>" title="<?php echo $this->get_product_link_title(); ?>" rel="nofollow" target="_blank">
<?php echo $this->get_product_title(); ?>
</a>
<div class="aawp-product__description">
<?php echo $this->get_product_description(); ?>
</div>
</div>
Thanks
I don't know what You actually want to achieve but this should be working good for You
<a class="aawp-product__title" href="<?php echo $this->get_product_url(); ?>" title="<?php echo $this->get_product_link_title(); ?>" rel="nofollow" target="_blank">
<h2><?php echo $this->get_product_title(); ?></h2>
</a>
Semantically, which is more correct: a in h2, or h2 in a?
Thanks, what I need is the aawp-product__title echo which returns a product title to be and H2 or H3 header.

Adding in links in Titles and Images with Custom Fields - WordPress

So my question is I need to add a link to a image and header in my wordpress site. Now I have tried to just add it next to it but nothing happens. It is using Custom Field Plugin.
Here is what the code looks like
<div class="calloutboxes">
<h2><?php echo $cbox['title']; ?></h2>
<img src="<?php echo $cbox['image']['sizes']['gallery_large'] ?>" height="<?php echo $cbox['image']['sizes']['gallery_large-height'] ?>" width="<?php echo $cbox['image']['sizes']['gallery_large-width'] ?>" alt="<?php echo $cbox['title']; ?>" />
<p>
<?php echo $cbox['description']; ?>
</p>
<a title="Read more about <?php echo $cbox['title']; ?>" href="<?php echo $cbox['read_more_url']; ?>"><i></i>Read More</a>
</div>
<?php endforeach;?>
</div>
</div>
Thanks

make an image link to each portfolio item in wordpress plugin

I am using a filterable plugin for portfolio items. This is the part of the code that display the thumbnail of each portfolio item and the title of the post. The link when is pressed is opens the image bigger but I would want that link to go to each portfolio item corresponding to the image thumbnail.
What would I have to modify?
<div class="view view-first <?php ps_the_terms(); ?>">
<?php ps_post_thumb(array(400,300)); ?>
<div class="mask">
<h2><?php the_title(); ?></h2>
<p><?php echo ps_post_excerpt(80); ?></p>
<a rel="colorbox" href="<?php the_permalink(); ?>" class="">View Details +</a>
</div>
</div>
<a rel="colorbox" href="<?php the_permalink(); ?>" class="">View Details +</a>
Remove rel="colorbox" as that's probably what the JavaScript is using for a hook.
You may also need to change <?php the_permalink(); ?> if that doesn't already go to the portfolio item.
If the permalink is not using the post link try:
<?php echo post_permalink( $ID ); ?>
https://codex.wordpress.org/Function_Reference/post_permalink

Categories