Hello,
Can I ask how you are currently including the dropdown list on your website? Is it code that you include in the post editor?
I was using the plugin Easy Code Manager, but it hasn’t been updated in a while so I’m trying an alternative.
That plugin let me place a form (my list, consisting of months to choose from) and Javascript into it and I could then set a shortcode that I could add to any page I wanted.
I’m currently looking at making my own custom shortcode. I placed my form and javascript into it’s own PHP file and called it in functions.php with include(‘bulletin.php’); but that just adds the drop-down list to the corner of every page. I don’t know how to make a shortcode from it to position it on a certain area of a page.
Hey,
Assuming that bulletin.php contains the content you want to output, you can write a shortcode like this:
add_shortcode( 'bulletin', function () {
ob_start();
include trailingslashit( WP_CONTENT_DIR ) . 'bulletin.php'
return ob_get_clean();
} );
You will of course need to adjust the path to the bulletin.php file appropriately.
Does that go into each page or do I add that to functions and refer to it by inserting a shortcode into each page?
You can add the code I posted as a snippet, and then use this shortcode in each post or page:
[bulletin]
I have a similar problem. I had a plugin called “PHP Code For Posts” that is broken and I’m trying to readd 36 radio feeds to your plugin using Shortcodes.
Their code was:
<?php
include “http://audiojournalfeeds.net/tg.htm”;
?>
and I named them [php snippit=1] then placed that on the page.
I’m trying to do this with your plugin. What I’m trying is not working.
Can you help? My client feeds radio shows to the blind at https://audiojournal.net.
Deb Perugi
Hi Deb,
You could try something like this:
add_shortcode( 'audio_feeds', function () {
$response = wp_remote_get( 'http://audiojournalfeeds.net/tg.htm' );
if ( is_array( $response ) ) {
return '<ul>' . $response['body'] . '</ul>';
}
return 'The feed could not be retrieved.';
} );
After adding this as a snippet, you should be able to use the [audio_feeds] shortcode in your posts and pages.
Thank you. There are 36 different feeds. tg.htm is just one. How do I set them apart on each page if the short code uses [audio_feeds] for each? [audio_feeds_1] and then [audio_feeds_2] ?
I just tried that and it worked!! I am using numbers at the end to sort out all 36 of the feeds.
You can make one shortcode work for all different feeds, if that would make things easier. What do the other feed URLs look like?
<?php
include “http://audiojournalfeeds.net/tg.htm”;
?>
and then each shortcode was added to the plugin list. They were named [code_snippet_1], [code_snippet_2], etc., which were placed on the page we wanted each program.
Okay, so if http://audiojournalfeeds.net/tg.htm is the URL to the first feed, what do the URLs to the other 35 look like? Just a number added to the end, like http://audiojournalfeeds.net/tg1.htm?