X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Blog System: Include an image in the home page section (https://forum.x-cart.com/showthread.php?t=76844)

welly 02-25-2019 01:26 AM

Blog System: Include an image in the home page section
 
Hi all

I am using the XC Blog System plugin for WordPress, which displays excerpts of the latest blog posts on my home page.

By default, those posts are displayed in a fairly unattractive manner, so to try and jazz it up a little, so I have created a module and AWidget.php file with a version of the getHTMLContentWidget() function. Because of the way this function displays the posts, I don't believe it is possible to do what I want through CSS alone.

Although my design skills are a bit rubbish, my module seems to be working, and I can modify the display of posts as I see fit through this function backed up with CSS.

I would like to include the post image in this display too, but as far as I am aware, the image is not available by default. There is certainly no reference to it in the function I am tinkering with, and I don't know how to get it, but I assume it is not part of the data query for the posts.

If you have done this already, or you happen to know how it can be done, can you give me some pointers? I can muddle through most things once I have a basic understanding, but I am not a php programmer. Keeping it simple would be extremely helpful. :lol:

Many thanks

Welly

tony_sologubov 02-26-2019 02:51 AM

Re: Blog System: Include an image in the home page section
 
Hi Welly,

I have just tried to create a blog post with the featured image and this featured image is already displayed alongside the post like this:
https://www.awesomescreenshot.com/image/3887474/324fb1774dbd2714f3254193592400b1

Could you please let me know what kind of image is not yet displayed, but it should be?

Thank you.

Tony

welly 02-26-2019 03:13 AM

Re: Blog System: Include an image in the home page section
 
2 Attachment(s)
Hi Tony

Many thanks for your reply.

In the blog page itself, the header images are displayed perfectly. I think that is what your image is showing.

However, I have the content section enabled on my home page, and this content section does not display an image. It only displays, and can only display (as far as I can tell), the heading, the excerpt, and the author for the last few posts.

For every post excerpt I display on my home page, I want to also display the corresponding header image.

I have attached two images. One shows what I created in XC4 using xCMS (Smack Digital), and the other shows what I have done so far with XC5 and the Blog System module. Formatting and layout aside, you can see that in the XC4 version, each post shows the image, and that is what I want to create in XC5.

I just don't know how to obtain the image so that I can display and style it.

EDIT: Somehow my image names are incorrect - the one that shows the images is in XC4, and the one without is XC5. Clever of me...

Many thanks

Welly

tony_sologubov 03-05-2019 03:33 AM

Re: Blog System: Include an image in the home page section
 
Hi @welly,

As far as I can see, you can pull post's image from WP using the 'get_the_post_thumbnail' method:
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/

In that sense, you can edit
Code:

\XLite\Module\QSL\WordPress\View\Plugins\RecentPosts\AWidget
class and define your own version of the getHTMLContentWidget() method which is responsible for displaying the menu widget.

I have just quickly tried to replace this piece of code:
Code:

              echo '<h5 class="entry-title"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h5>';

with the next one:
Code:

              echo '<h5 class="entry-title"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h5>';
                echo get_the_post_thumbnail();


and it has kind of worked out.

Let me know if you need any further help.

Tony

Quote:

Originally Posted by welly
I have attached two images. One shows what I created in XC4 using xCMS (Smack Digital), and the other shows what I have done so far with XC5 and the Blog System module. Formatting and layout aside, you can see that in the XC4 version, each post shows the image, and that is what I want to create in XC5.

I just don't know how to obtain the image so that I can display and style it.


welly 03-05-2019 05:49 AM

Re: Blog System: Include an image in the home page section
 
Hi Tony

Yes, I think this will do the trick.

That function gets the post 'Featured Image', which I haven't used so far, but it does work. I just need to place the image and finesse it with css, and we should be good to go.

Many thanks

Welly


All times are GMT -8. The time now is 06:39 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.