Jump to content

Recommended Posts

Hi Everybody.

 

Apologies if I've not posted this in the correct forum, but the following line of WordPress code displays the ‘Title’ of my individual blog posts in the Sidebar.

 

<a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_ID(); ?></a>

 

Can somebody please help me tweak it so it displays both the ‘Title’ and ‘Subtitle’ of each post please? So far I’ve tried adding the ‘Subtitle’ at the end, like this:

 

<a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_ID(); ?><span class="subtitle"><?php the_subtitle(); ?></span></a>

 

This works in the sense that both the ‘Title’ and ‘Subtitle’ are displayed (both of which are styled in slightly different colours using a separate CSS file), but while the ‘Title’ changes font colour on mouse-hover, the ‘Subtitle’ doesn’t (I’m guessing because I’ve wrapped it in a span class). What I’m really hoping to do is have the ‘Title’ displayed in one colour and the ‘Subtitle’ in a slightly different colour, but for both ‘Title’ and ‘Subtitle’ to change to the same colour when the mouse hovers over either one of them. I’m still building my site, but you can see the Sidebar as it stands, here http://www.retelevise.com.

 

I don’t know if this is even possible and have not had any feedback on the WordPress support forum, so was really hoping one of the PHP experts here might be able to help me please? Bear in mind I'm a complete PHP novice.

 

Thanks,

SN.

Link to comment
https://forums.phpfreaks.com/topic/288795-wordpress-php-query/
Share on other sites

This isn't really a PHP or WP issue, because the output is what you want it to be. What it is is a CSS issue, and if your on-hover color isn't right for the span, then you'll need to add/edit some CSS to make it right.

 

So where you have CSS rules for "a" and "a:hover", you're also going to need one for "a span:hover". This wouldn't normally be the case, but it seems that you might have a rule that this span is inheriting from.

Link to comment
https://forums.phpfreaks.com/topic/288795-wordpress-php-query/#findComment-1481066
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.