How to Include Custom Post Content From Plugin

Template filters have to return the name of a template file, not content. Their purpose is to override template selection with a different template. If you want to modify the content output within the content of a template, then you need to add a filter to the_content. function my_the_content_filter( $content ) { global $post; if … Read more

Changing plugin options from theme functions file?

For reference, you may want to read the update_option documentation. The arguments you are passing are completely unrelated. However, your third technique is the closest, you have to update all the options in the the update_option call, not just the one option you want. This is because of how the plugin is storing it’s options … Read more

Retrieve options set through a plugin

First of all, the_content is a filter hook and not action. Secondly, it will only work when post content will be access on your site front end. You can probably make use of global variables instead. e.g. $options = get_option( ‘wpglobalsettings’ ); and then use wherever you want to access as follows – global $options;

If post exists in the database – each time goes on `else`

I suspect that PHP considers the value of $wpdb->get_row(“SELECT * FROM wp_posts WHERE post_title=”” . $title . “””, ‘ARRAY_A’); to be true no matter what (see also this). You’ll have to count the number of rows that are returned Try something like this instead: $query = “SELECT COUNT(*) FROM wp_posts WHERE post_title=”$title””; $count = $wpdb->get_var($query); … Read more

Form Plugin for Api Requests which is used via Shortcode

First, create a function to process the form. In the shortcode function, first process the form and then return any form/message that you want to display to the user. /** * Plugin Name: NewsletterFormConnector * Description: Newsletter Form to connect to Newsletter Api * Author: emjay * Version: 1.0 */ //Add function file require_once(plugin_dir_path(__FILE__) . … Read more

Executing Javascript in Plugin

Based on what I can see, it looks like your calling the create_map function incorrectly. add_shortcode() takes 2 parameters, the name of the shortcode and the function that gets rendered when called. The array you are passing is how to call a method inside of a class. You’re basically saying call the create_map method from … Read more