• Resolved tchen200

    (@tchen200)


    Hello,

    I want to move the front page widget I have for recent posts to the box I have for updates at the right on the home page. How do I decrease the width the widget takes and move its location? Also would I be able to customize the background color too by setting the background-color of the widget to something?

    Also I want to remove the widget-title, however I can’t find widgets in my front-page.php, where would I make the edits for widgets?

    Also, is there a way to make the posts unclickable? What I’m trying to do is have a small amount of text show up that can be added/edited directly in the wp-admin location in the web browser without having to go into the files. This way seems to work, would there be a better way to do this?

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi there,

    Instead of moving the widget, I think the most straightforward approach would be you for you to add a shortcode that pulls in your latest posts to the LexploreUpdates section of your site.

    The first step to do that is to enable Jetpack’s Shortcode Embeds module.

    The [archives] shortcode can be then be added directly within the LexploreUpdates section in your editor.

    By default, that shortcode will pull in a list of all of your site’s posts. You can customise it by following the steps here. For example, to display a list of 10 posts in descending of order of date, the following would be used:

    [archives limit=10 order=desc]

    By using the above shortcode rather than moving the widget, you will automatically inherit the background colour you’ve set for the LexploreUpdates section and won’t need to worry about removing the widget’s title.

    Let me know what you think of that option!

    Also, is there a way to make the posts unclickable? What I’m trying to do is have a small amount of text show up that can be added/edited directly in the wp-admin location in the web browser without having to go into the files.

    You could eventually use pointer-events property with some custom CSS, as explained here:

    https://css-tricks.com/almanac/properties/p/pointer-events/

    Let me know once you’re setup with the list of posts in the location you want on your site and I can then help with specific CSS.

    Thread Starter tchen200

    (@tchen200)

    Hello,

    The way I have the updates area set up is I added it to the front-page.php in my child theme. Where do I put the [archives limit=10 order=desc] shortcode? If I add it directly to the php file it just shows up as text.

    I tried the shortcode in the wordpress visual editor for a new page, and it does display the posts, however for my front page, I don’t use the edit page button in wp-admin in the web browser, I just set up the format in a child theme. What should I do?

    Thanks.

    Ah, I see! In that case, we could create some code using the the WP_Query class that pulls in a static, unclickable list of your 10 most recent posts:

    <ul>
    	<?php $the_query = new WP_Query( 'posts_per_page=10' ); ?>
    	<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
    		<li><?php the_title(); ?></li>
    	<?php
    		endwhile;
    		wp_reset_postdata();
    	?>
    </ul>

    Add the above in your child theme’s .php file and let me know how you get on.

    Thread Starter tchen200

    (@tchen200)

    Hello,

    Your solution works, thanks for the help!

    You’re most welcome! I’m glad that helped out.

    Hi great post and very helpful. Can I ask if I wanted to position a specific shortcode from a plugin to the front page of a theme can I just use the CSS or php of home page? Thanks

    • This reply was modified 7 years, 12 months ago by ganton.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to customize widgets location and style’ is closed to new replies.