Surrogate
Forum Replies Created
-
Forum: Hacks
In reply to: Use get_template_part() into a pluginWhat you want to do ( i think if i understood you correctly, if not sorry ) is execute code from a plugin. folder and input it in template.
try this :
I will go full way on how to do it.
Step one. register a plugin, in your plugin file add this :
function activate_your_plugin() { add_option( 'Activated_Plugin', 'Plugin-Slug' ); /* activation code here */ } register_activation_hook( __FILE__, 'activate_your_plugin' );Step 2.
You need code that will create page when your plugin is loaded, and on that page output your wordpress looops.
So take this function, it will create that page :
1). Page title // choose title.
2). Page slug. // choose slug.
3). post type. // page.
4). shortcode. // Here you input a shortcode WITH YOUR CUSTON LOOPS ( your code that you need to output. ).
5) Optional template name, template name you want to use, if not leave it blank.function create_custom_loop_page( $title, $slug, $post_type, $shortcode, $template = null ) { //Check if the page with this name exists. if(!get_page_by_title($title)) { // if not : $page_id = -1; $page_id = wp_insert_post( array( 'comment_status' => 'open', 'ping_status' => 'open', 'post_content' => $shortcode, 'post_author' => 1, // Administrator is creating the page 'post_title' => $title, 'post_name' => strtolower( $slug ), 'post_status' => 'publish', 'post_type' => strtolower( $post_type ) ) ); // If a template is specified in the function arguments, let's apply it if( null != $template ) { update_post_meta( get_the_ID(), '_wp_page_template', $template ); } // end if return $page_id; } }Step 3 , put your loop code in a shortcode :
function custom_loop_shortcode(){ echo 'I put my custom loop stuff here'; } add_shortcode('your_shortcode_name', 'custom_loop_shortcode');Step 4, Now we call our function once only to execute this :
function load_plugin() { if ( is_admin() && get_option( 'Activated_Plugin' ) == 'Plugin-Slug' ) { delete_option( 'Activated_Plugin' ); /* do stuff once right after activation */ create_custom_loop_page(('Custom Loop Page', 'custom-loop-page', 'page', '[your_shortcode_name]' ); // Also last parameter specific template name, else wp will choose default one. ( recomend trying without it first ). } } add_action( 'admin_init', 'load_plugin' );Hope this helps.
Cheers!
Forum: Fixing WordPress
In reply to: Error: switchEditors is not definedOh this is just awesume, i somehow managed to fix it, but i dont know how, i dont get the error any more, however now Edit Image button is missing so i cant access the screen where i crop / resize the image..
Forum: Fixing WordPress
In reply to: Error: switchEditors is not definedIts a fairly large website, 50-60 k visits a day, 300mb database. On a custom theme i developed.
I am trying to avoid shuting everything down and reinstalling wordpress.
dont think its anything in functions php, do it does have 2000 lines of various code in it.
So far i am prety sure it is a tinymce problem. by googling i found out that there is an extension in tinymce called switchEditors
so its probably something related to it.
I also noticed there is another error, when i press crop at the gallery interface however this one is related to scissors plugin, which might be related or might not be related to this.
ReferenceError: scissorsShowCrop is not defined
https://hotsport.rs/wp-admin/post.php?post=95608&action=edit/132