How to add header H2 in PHP class - php

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.

Related

Show the summary in the title card

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">

Redirect WordPress Header Logo To Specific URL

I'm trying to redirect the header logo to a specific URL as well. I came across this site during my research. Please take a look at the following code and let me know exactly what modifications needs to be made to accomplish this. Thanks in advance.
<h1 class="<?php echo $class; ?>">
<a href="<?php echo esc_url(home_url('/')); ?>" title="<?php echo esc_attr(get_bloginfo('name', 'display')); ?>" rel="home">
<?php echo $logo; ?>
</a>
</h1>
Thanks,
Jon
Remove <?php echo esc_url(home_url('/')); ?> and replace it with your URL like so:
<h1 class="<?php echo $class; ?>">
<a href="https://example.net" title="<?php echo esc_attr(get_bloginfo('name', 'display')); ?>" rel="home">
<?php echo $logo; ?>
</a>
</h1>

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

Changing PHP request into fixed URL. (Wordpress Template Header)

Very short question but it seems like i'm just to dumb.
<div class="header-content" id="header-content">
<div class="container">
<div id="logo">
<a href="<?php echo home_url(); ?>" title="<?php bloginfo('name'); ?>">
<?php
if(isset($theme_options['logo']) && isset($theme_options['logo']['url']) && $theme_options['logo']['url'] != ''){
echo '<img src="'.$theme_options['logo']['url'].'" alt="" />';
}
else{
echo '<img src="'.get_template_directory_uri().'/assets/img/placeholder/logo.png" alt="" />';
}
?>
</a>
</div>
Since there is only just one "href" in it i thought i could change this line:
<a href="<?php echo home_url(); ?>" title="<?php bloginfo('name'); ?>">
Into:
<a href="http://example.com/" title="<?php bloginfo('name'); ?>">
But after a cache clear and reload nothing changed. In case you didnt figured out what i try, its simple. I want to change the link the blog logo is leading to without changing the blog home url.

do_shortcodes in Wordpress

I'm having some trouble getting my "WP Private" plugin to work through my TEMPLATE, not a post/page. When searching Google, I have no problems with finding out how to implement a SINGLE shortcode, but I'm not able to find how to implement an opening/closing short tag, which I know is quite common.
Here's my code. I must be having another syntax issue! The opening/closing tags that I used in this case have proven successful on another website I tried. But it's not working in this case.
<?php echo do_shortcode ('[protected]
<!--<h2><?php the_title(); ?></h2>-->
<ul style="border-bottom: 1px solid #d8d8d8" class="<?php echo get_option('minimax_list_layout'); ?>">
<?php
query_posts(array ('post__in' => array( 569)));
if (have_posts()) : while (have_posts()) : the_post();
?>
<li style="border-bottom: 1px solid #d8d8d8; padding-bottom:20px" class="clearfix">
<?php if ( get_option('minimax_list_layout') == 'style-two' ) { ?>
<h3 style="font-family:nobile; font-weight:normal; font-size:1.8em"><a style="text-decoration:none" title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<cite><?php the_time('d M Y') ?> </cite>
<?php if ( has_post_thumbnail() ) { ?>
<a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_post_thumbnail('thumb_post_wide', 'class=head'); ?></a>
<?php } ?>
<p style="font-family:nobile; font-size:1.15em"><?php echo ShortenText( $post->post_content, 300 ); ?></p>
<a class="detail" href="<?php the_permalink() ?>">Continue reading</a>
<?php } else { ?>
<?php if ( has_post_thumbnail() ) { ?>
<a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_post_thumbnail('thumb_post_1'); ?></a>
<?php } ?>
<div class="post-summary">
<h3 style="font-family:nobile; font-weight:normal; font-size:1.8em"><a style="text-decoration:none" title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<!--<cite style="font-style:normal; font-weight:bold; font-family:nobile"><?php the_time('d M Y') ?> </cite>-->
<p style="font-family:nobile; font-size:1.15em"><?php echo ShortenText( $post->post_content, 220 ); ?></p>
<a style="font-family:nobile" class="detail" href="<?php the_permalink() ?>">Continue reading</a>
</div><!-- end post-summary -->
<?php } ?>
</li>
<?php endwhile; ?>
<?php if (show_posts_nav()) : ?>
<div id="post-navigation" class="clearfix">
<span class="previous"><?php next_posts_link('Older Entries') ?></span>
<span class="next"><?php previous_posts_link('Newer Entries') ?></span>
</div>
<?php endif; wp_reset_query(); ?>
<?php else: ?>
<p><?php _e('Sorry, no pages matched your criteria.'); ?></p>
<?php endif; ?>
</ul><!-- end posts-list -->
[/protected]') ?>
You are writing very weird things here. By doing this:
echo do_shortcode ('[protected]
<!--<h2><?php the_title(); ?></h2>-->
you are submitting the php code of the template as a string to the function and then echo it, but it is not going to be interpreted by PHP engine. Moreover, the first single quote will create a syntax error. You have to enable ob (output buffering), run the template code, get the result from the buffer, wrap it in your shortcode and than submit the result to function do_shortcode.
http://www.php.net/ob_start and http://www.php.net/ob_get_clean
ps: and I still think that you do not need it. Why do you need a shortcode here, if you can use "if" statement and just skip the whole section of the code? I do not know what you are doing in your plugin, but if you are trying to hide the part of the template then "if" is the easiest way to implement your idea.
if (check_if_allowed())
{
// your part of template is here
}

Categories