Can WP Plugins Alter themes

8 replies
I'm wondering if it's possible for a WP plugin to alter the main loop, hook into the main loop and override it.

Or would it be more practical to just create a theme with the required functionality?


So for instance the main loop prints out all posts on the blog in standard blog style, newest first in descending order.

Could a plugin change the main theme's files so that instead of doing that it just showed the 3 latest posts? Or is there simply too many theme variations.
#alter #plugins #themes
  • Profile picture of the author cgimaster
    Yes you can make a plugin to change it or make a custom template and define as the index or use a custom query or Function Reference/query posts « WordPress Codex

    In addition here is one plugin that changes main loop if you wanted to look into the code yourself:
    http://wordpress.org/extend/plugins/custom-post-order/

    And one for the post limits:
    http://wordpress.org/extend/plugins/custom-post-limits/

    You will have it easier by looking into their code if you want to make your own.
    {{ DiscussionBoard.errors[7264699].message }}
    • Profile picture of the author gcampton
      Originally Posted by cgimaster View Post

      Yes you can make a plugin to change it or make a custom template and define as the index or use a custom query or Function Reference/query posts « WordPress Codex

      In addition here is one plugin that changes main loop if you wanted to look into the code yourself:
      WordPress › Custom Post Order « WordPress Plugins

      And one for the post limits:
      WordPress › Custom Post Limits « WordPress Plugins

      You will have it easier by looking into their code if you want to make your own.
      Thanks mate, actually not quite what I was looking for. But hopefully those plugins will shed some light.

      I didn't want to change the loop using that function, I wanted to insert some code into the loop via a plugin.
      Just not sure how I can change template files, when i don't know what the template will be at any one time...

      For instance, Bob could be using TwentyEleven, in which case I need to change archives, index, page, search. But Sarah could be using a Professional $120 theme which needs the above and 'portfolio', 'sitemap', 'timeline' and a couple others changed.

      I think my best bet is to create a theme, because I can't see how it could possibly be done using a plugin when there's so many theme variations...
      Signature

      ()_()
      (o.O) <<<----- This bunny is more ethical and mostly made of pixels.
      (")("")

      {{ DiscussionBoard.errors[7266818].message }}
  • Profile picture of the author cgimaster
    No problem been there.
    {{ DiscussionBoard.errors[7266987].message }}
  • Profile picture of the author gcampton
    Yes you can make a plugin to change it
    That's what I need to figure out, if it's possible or not.
    Signature

    ()_()
    (o.O) <<<----- This bunny is more ethical and mostly made of pixels.
    (")("")

    {{ DiscussionBoard.errors[7267027].message }}
  • Profile picture of the author cgimaster
    You could try to hook see if this is what u need:
    Plugin API/Action Reference/pre get posts « WordPress Codex

    Well you can register it to the database with a plugin so you can handle each separated.
    {{ DiscussionBoard.errors[7267199].message }}
  • Profile picture of the author SteveJohnson
    You'd be getting into theme territory with a plugin like that, and I rather think you'll be opening yourself up to a ton of support requests. What if the user's theme doesn't use the 'standard' WP loop to display content? What about custom post types?
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[7267608].message }}
  • Profile picture of the author gcampton
    Thanks CGI I think that's what I need...

    Is there a list of all Action Hooks and the other kind of hook... forgot what it's called.
    Like a phpdoc (javadoc style) for WP?
    Signature

    ()_()
    (o.O) <<<----- This bunny is more ethical and mostly made of pixels.
    (")("")

    {{ DiscussionBoard.errors[7271445].message }}
  • {{ DiscussionBoard.errors[7271476].message }}

Trending Topics