1

I'm new to WordPress. So, I have installed a plugin to display recent posts (that's it: https://wordpress.org/plugins/flexible-posts-widget/). This plugin have a widget. And now I want to change widget's template for my needs. I found it in plugin_folder/views/default.php. As I know, it is bad practice to edit files directly in plugin folder. So, how can I copy this file to work with him in my own theme?.

2
  • 1
    Do you even need the plugin to view recent posts? It should be quite simple to add that functionality into the theme yourself without a plugin.
    – JoeMoe1984
    Commented Jan 6, 2016 at 8:58
  • May be. Anyway, I don't know how to show posts from Custom Post Types without plugin. Standard widget called "Recent Posts" does not show it. The fact is that my WP experience - 1 week, so it's no wonder that I don't know very simple things.
    – Vlodko
    Commented Jan 6, 2016 at 9:15

1 Answer 1

2

Here is a little code snippet to get you started. This will query through the most recent custom post types named "custom_post_type". Change this value to the name of the custom post you wish to query.

<?php 

$args = array(
    'post_type' => 'custom_post_type', // <-- make sure to use the name of your custom post type here
);

$query = new WP_Query($args);

if( $query->have_posts() ) {
    while( $query->have_posts() ) {
        the_post();
        echo "<h1>" . get_the_title() . "</h1>";

    }
}

wp_reset_postdata();
?>

No plugin needed. If you wish to do some extra reading on custom queries for posts you can use the Wordpress Codex site as a reference. Here is the WP_Query page: https://codex.wordpress.org/Class_Reference/WP_Query

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.