Move plugin modification outside of plugin files





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm using a plugin called wp show posts to list posts from specific categories on pages. I'm also using Advanced Custom Fields, with which I added meta values to all of the posts (active, new, and/or closed). I modified the wp show posts plugin to display the meta data values on each post title when they're in list view.



                    // The title
if ( $settings[ 'include_title' ] || ( $settings[ 'include_author' ] && 'below-title' == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && 'below-title' == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && 'below-title' == $settings[ 'terms_location' ] ) ) : ?>

<?php if( get_field('new') ): ?>
<h2 class="new"><?php the_field('new'); ?></h2>
<?php endif; ?>
<?php if( get_field('active') ): ?>
<h2 class="active"><?php the_field('active'); ?></h2>
<?php endif; ?>
<?php if( get_field('closed') ): ?>
<h2 class="closed"><?php the_field('closed'); ?></h2>
<?php endif; ?>

<header class="wp-show-posts-entry-header">


You can see the code I added there in between the title function and header function.



Now that I've modified the plugin, I won't be able to update it.



Where can I place this code so it won't be inside the plugin files?










share|improve this question























  • Unless the plugin includes a hook for what you want to do, there is no real way to modify its output without modifying the plugin itself. You'll likely either need to re-add your code whenever you update the plugin, or I suppose you could generate your html via PHP and then insert it where you want it to go via Javascript?

    – emmzee
    Nov 23 '18 at 14:48











  • Editing plugin's code directly isn't recommended for that very same reason: you won't be able to update it without losing your custom modifications, which could make your site insecure in the future. Instead, you should try using the filter/action hooks provided by the plugin to modify its behavior whenever possible. Please check my answer below and, if it helped, consider marking it as accepted.

    – cabrerahector
    Nov 23 '18 at 14:51













  • Got it, thank you all for your input. I'll stay away from editing the plugin.

    – adbe
    Nov 23 '18 at 16:51


















0















I'm using a plugin called wp show posts to list posts from specific categories on pages. I'm also using Advanced Custom Fields, with which I added meta values to all of the posts (active, new, and/or closed). I modified the wp show posts plugin to display the meta data values on each post title when they're in list view.



                    // The title
if ( $settings[ 'include_title' ] || ( $settings[ 'include_author' ] && 'below-title' == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && 'below-title' == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && 'below-title' == $settings[ 'terms_location' ] ) ) : ?>

<?php if( get_field('new') ): ?>
<h2 class="new"><?php the_field('new'); ?></h2>
<?php endif; ?>
<?php if( get_field('active') ): ?>
<h2 class="active"><?php the_field('active'); ?></h2>
<?php endif; ?>
<?php if( get_field('closed') ): ?>
<h2 class="closed"><?php the_field('closed'); ?></h2>
<?php endif; ?>

<header class="wp-show-posts-entry-header">


You can see the code I added there in between the title function and header function.



Now that I've modified the plugin, I won't be able to update it.



Where can I place this code so it won't be inside the plugin files?










share|improve this question























  • Unless the plugin includes a hook for what you want to do, there is no real way to modify its output without modifying the plugin itself. You'll likely either need to re-add your code whenever you update the plugin, or I suppose you could generate your html via PHP and then insert it where you want it to go via Javascript?

    – emmzee
    Nov 23 '18 at 14:48











  • Editing plugin's code directly isn't recommended for that very same reason: you won't be able to update it without losing your custom modifications, which could make your site insecure in the future. Instead, you should try using the filter/action hooks provided by the plugin to modify its behavior whenever possible. Please check my answer below and, if it helped, consider marking it as accepted.

    – cabrerahector
    Nov 23 '18 at 14:51













  • Got it, thank you all for your input. I'll stay away from editing the plugin.

    – adbe
    Nov 23 '18 at 16:51














0












0








0








I'm using a plugin called wp show posts to list posts from specific categories on pages. I'm also using Advanced Custom Fields, with which I added meta values to all of the posts (active, new, and/or closed). I modified the wp show posts plugin to display the meta data values on each post title when they're in list view.



                    // The title
if ( $settings[ 'include_title' ] || ( $settings[ 'include_author' ] && 'below-title' == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && 'below-title' == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && 'below-title' == $settings[ 'terms_location' ] ) ) : ?>

<?php if( get_field('new') ): ?>
<h2 class="new"><?php the_field('new'); ?></h2>
<?php endif; ?>
<?php if( get_field('active') ): ?>
<h2 class="active"><?php the_field('active'); ?></h2>
<?php endif; ?>
<?php if( get_field('closed') ): ?>
<h2 class="closed"><?php the_field('closed'); ?></h2>
<?php endif; ?>

<header class="wp-show-posts-entry-header">


You can see the code I added there in between the title function and header function.



Now that I've modified the plugin, I won't be able to update it.



Where can I place this code so it won't be inside the plugin files?










share|improve this question














I'm using a plugin called wp show posts to list posts from specific categories on pages. I'm also using Advanced Custom Fields, with which I added meta values to all of the posts (active, new, and/or closed). I modified the wp show posts plugin to display the meta data values on each post title when they're in list view.



                    // The title
if ( $settings[ 'include_title' ] || ( $settings[ 'include_author' ] && 'below-title' == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && 'below-title' == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && 'below-title' == $settings[ 'terms_location' ] ) ) : ?>

<?php if( get_field('new') ): ?>
<h2 class="new"><?php the_field('new'); ?></h2>
<?php endif; ?>
<?php if( get_field('active') ): ?>
<h2 class="active"><?php the_field('active'); ?></h2>
<?php endif; ?>
<?php if( get_field('closed') ): ?>
<h2 class="closed"><?php the_field('closed'); ?></h2>
<?php endif; ?>

<header class="wp-show-posts-entry-header">


You can see the code I added there in between the title function and header function.



Now that I've modified the plugin, I won't be able to update it.



Where can I place this code so it won't be inside the plugin files?







php wordpress






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 14:17









adbeadbe

187




187













  • Unless the plugin includes a hook for what you want to do, there is no real way to modify its output without modifying the plugin itself. You'll likely either need to re-add your code whenever you update the plugin, or I suppose you could generate your html via PHP and then insert it where you want it to go via Javascript?

    – emmzee
    Nov 23 '18 at 14:48











  • Editing plugin's code directly isn't recommended for that very same reason: you won't be able to update it without losing your custom modifications, which could make your site insecure in the future. Instead, you should try using the filter/action hooks provided by the plugin to modify its behavior whenever possible. Please check my answer below and, if it helped, consider marking it as accepted.

    – cabrerahector
    Nov 23 '18 at 14:51













  • Got it, thank you all for your input. I'll stay away from editing the plugin.

    – adbe
    Nov 23 '18 at 16:51



















  • Unless the plugin includes a hook for what you want to do, there is no real way to modify its output without modifying the plugin itself. You'll likely either need to re-add your code whenever you update the plugin, or I suppose you could generate your html via PHP and then insert it where you want it to go via Javascript?

    – emmzee
    Nov 23 '18 at 14:48











  • Editing plugin's code directly isn't recommended for that very same reason: you won't be able to update it without losing your custom modifications, which could make your site insecure in the future. Instead, you should try using the filter/action hooks provided by the plugin to modify its behavior whenever possible. Please check my answer below and, if it helped, consider marking it as accepted.

    – cabrerahector
    Nov 23 '18 at 14:51













  • Got it, thank you all for your input. I'll stay away from editing the plugin.

    – adbe
    Nov 23 '18 at 16:51

















Unless the plugin includes a hook for what you want to do, there is no real way to modify its output without modifying the plugin itself. You'll likely either need to re-add your code whenever you update the plugin, or I suppose you could generate your html via PHP and then insert it where you want it to go via Javascript?

– emmzee
Nov 23 '18 at 14:48





Unless the plugin includes a hook for what you want to do, there is no real way to modify its output without modifying the plugin itself. You'll likely either need to re-add your code whenever you update the plugin, or I suppose you could generate your html via PHP and then insert it where you want it to go via Javascript?

– emmzee
Nov 23 '18 at 14:48













Editing plugin's code directly isn't recommended for that very same reason: you won't be able to update it without losing your custom modifications, which could make your site insecure in the future. Instead, you should try using the filter/action hooks provided by the plugin to modify its behavior whenever possible. Please check my answer below and, if it helped, consider marking it as accepted.

– cabrerahector
Nov 23 '18 at 14:51







Editing plugin's code directly isn't recommended for that very same reason: you won't be able to update it without losing your custom modifications, which could make your site insecure in the future. Instead, you should try using the filter/action hooks provided by the plugin to modify its behavior whenever possible. Please check my answer below and, if it helped, consider marking it as accepted.

– cabrerahector
Nov 23 '18 at 14:51















Got it, thank you all for your input. I'll stay away from editing the plugin.

– adbe
Nov 23 '18 at 16:51





Got it, thank you all for your input. I'll stay away from editing the plugin.

– adbe
Nov 23 '18 at 16:51












1 Answer
1






active

oldest

votes


















0














WP Show Posts has an action hook called wpsp_before_title that you can use to insert content before the heading:



/**
* Adds ACF data before the heading.
*
* @param array $settings
*/
function wpsp_show_acf_data( $settings ){
<?php if( get_field('new') ): ?>
<h2 class="new"><?php the_field('new'); ?></h2>
<?php endif; ?>

<?php if( get_field('active') ): ?>
<h2 class="active"><?php the_field('active'); ?></h2>
<?php endif; ?>

<?php if( get_field('closed') ): ?>
<h2 class="closed"><?php the_field('closed'); ?></h2>
<?php endif; ?>
}
add_action( 'wpsp_before_title', 'wpsp_show_acf_data' );


Add this to your theme's functions.php file (or to a standalone plugin) and it should work.



Remember to undo the modifications you made to the plugin since you won't need them anymore.






share|improve this answer
























  • Awesome, thanks a lot! That's perfect.

    – adbe
    Nov 23 '18 at 16:50












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448337%2fmove-plugin-modification-outside-of-plugin-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














WP Show Posts has an action hook called wpsp_before_title that you can use to insert content before the heading:



/**
* Adds ACF data before the heading.
*
* @param array $settings
*/
function wpsp_show_acf_data( $settings ){
<?php if( get_field('new') ): ?>
<h2 class="new"><?php the_field('new'); ?></h2>
<?php endif; ?>

<?php if( get_field('active') ): ?>
<h2 class="active"><?php the_field('active'); ?></h2>
<?php endif; ?>

<?php if( get_field('closed') ): ?>
<h2 class="closed"><?php the_field('closed'); ?></h2>
<?php endif; ?>
}
add_action( 'wpsp_before_title', 'wpsp_show_acf_data' );


Add this to your theme's functions.php file (or to a standalone plugin) and it should work.



Remember to undo the modifications you made to the plugin since you won't need them anymore.






share|improve this answer
























  • Awesome, thanks a lot! That's perfect.

    – adbe
    Nov 23 '18 at 16:50
















0














WP Show Posts has an action hook called wpsp_before_title that you can use to insert content before the heading:



/**
* Adds ACF data before the heading.
*
* @param array $settings
*/
function wpsp_show_acf_data( $settings ){
<?php if( get_field('new') ): ?>
<h2 class="new"><?php the_field('new'); ?></h2>
<?php endif; ?>

<?php if( get_field('active') ): ?>
<h2 class="active"><?php the_field('active'); ?></h2>
<?php endif; ?>

<?php if( get_field('closed') ): ?>
<h2 class="closed"><?php the_field('closed'); ?></h2>
<?php endif; ?>
}
add_action( 'wpsp_before_title', 'wpsp_show_acf_data' );


Add this to your theme's functions.php file (or to a standalone plugin) and it should work.



Remember to undo the modifications you made to the plugin since you won't need them anymore.






share|improve this answer
























  • Awesome, thanks a lot! That's perfect.

    – adbe
    Nov 23 '18 at 16:50














0












0








0







WP Show Posts has an action hook called wpsp_before_title that you can use to insert content before the heading:



/**
* Adds ACF data before the heading.
*
* @param array $settings
*/
function wpsp_show_acf_data( $settings ){
<?php if( get_field('new') ): ?>
<h2 class="new"><?php the_field('new'); ?></h2>
<?php endif; ?>

<?php if( get_field('active') ): ?>
<h2 class="active"><?php the_field('active'); ?></h2>
<?php endif; ?>

<?php if( get_field('closed') ): ?>
<h2 class="closed"><?php the_field('closed'); ?></h2>
<?php endif; ?>
}
add_action( 'wpsp_before_title', 'wpsp_show_acf_data' );


Add this to your theme's functions.php file (or to a standalone plugin) and it should work.



Remember to undo the modifications you made to the plugin since you won't need them anymore.






share|improve this answer













WP Show Posts has an action hook called wpsp_before_title that you can use to insert content before the heading:



/**
* Adds ACF data before the heading.
*
* @param array $settings
*/
function wpsp_show_acf_data( $settings ){
<?php if( get_field('new') ): ?>
<h2 class="new"><?php the_field('new'); ?></h2>
<?php endif; ?>

<?php if( get_field('active') ): ?>
<h2 class="active"><?php the_field('active'); ?></h2>
<?php endif; ?>

<?php if( get_field('closed') ): ?>
<h2 class="closed"><?php the_field('closed'); ?></h2>
<?php endif; ?>
}
add_action( 'wpsp_before_title', 'wpsp_show_acf_data' );


Add this to your theme's functions.php file (or to a standalone plugin) and it should work.



Remember to undo the modifications you made to the plugin since you won't need them anymore.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 14:52









cabrerahectorcabrerahector

1,8372814




1,8372814













  • Awesome, thanks a lot! That's perfect.

    – adbe
    Nov 23 '18 at 16:50



















  • Awesome, thanks a lot! That's perfect.

    – adbe
    Nov 23 '18 at 16:50

















Awesome, thanks a lot! That's perfect.

– adbe
Nov 23 '18 at 16:50





Awesome, thanks a lot! That's perfect.

– adbe
Nov 23 '18 at 16:50




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448337%2fmove-plugin-modification-outside-of-plugin-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()