I am trying to get Wordfaire live blogging embed code to work on my site and having some problems. I created a new page for my live blog feed on site site and added the embed code to the html page in wordpress. When I test it out and try a test live blog nothing runs on the page.
Is there a trick to getting it to work on wordpress??
Thanks in advance to anyone that can assist!
It sounds to me that you are using the HTML view of the WordPress editor to paste the embed code, correct?
A better way would be to make a simple plugin that will create a shortcode with the embed code, then you use that shortcode to display the embed code on your page.
Example:
embed-shortcode-plugin.php
<?php
/*
Plugin Name: Plugin Name
Plugin URI: http://pluginurl.com
Description: Plugin description
Version: 1.0
Author: Author Name
Author URI: http://authorurl.com
*/
function embed_shortcode($atts,$content=null){
extract(shortcode_atts(array('optionname'=>'defaultvalue'),$atts));
// The extract() function above will allow you to do [shortcode optionname="defaultvalue"] in your pages and use $optionname to get the value below
// The extract() line is optional and can be removed
// $optionname = defaultvalue
return 'put your embed code here';
}
add_shortcode('shortcode','embed_shortcode');
// This will add the shortcode 'shortcode': [shortcode], change to whatever
?>
Put that in your plugins folder and then activate it. Alternatively, you could remove the stuff between the /* and */ and put that code right in your theme's functions.php file and it will run the same.
Related
currently my theme on WordPress is Neve , and my posts all over the blog shows the following meta info :
https://i.stack.imgur.com/ynu71.jpg
where :
1- post title
2- post author
3- post date
4- post category
i want to replace these post meta with similar to this:
https://i.stack.imgur.com/Xywa9.jpg
for this purpose i have created a child theme and then installed snippet plugin to add php code easily and deactivate it once it is not working . unfortunately i could not find the code that can do the required modifications on that post meta :
https://i.stack.imgur.com/uwCrS.jpg
can any one provide a full php code to modify all these changes in one time after pasting into snippet ? or if there is another way i can do it ?
You'll have to create a child theme (already done) where you can override the current blog post template, instead of using a snippet plugin. To do this, copy the blog post template file from your theme and add it to your child theme.
WordPress will now read your child theme template instead of your theme's template, and you can easily modify the DOM from there, and shape the layout/text however way you want. (You can use the theme editor built-in in WordPress to modify the new child theme file. No plugin required.)
This is the proper way to modify a post page without plugins, and you can easily grab thing such as a post date, author, etc. via WordPress' built-in function. Example of how to get the author name of a WordPress post in PHP.
As for, 'latest edition' date, I will lend you a snippet I wrote for a client as WordPress. This will return the date at which a post has been modified as long as it is different from the publishing date (tweaks are common right after publication so it's a tad pointless to show a "last edited date" as the same as the publication date).
function current_post_last_edited_date_formatted() {
if(get_the_modified_date() !== get_the_date()) {
return '<p class="last-edited"> Last edited <span class="data">'.current_post_last_edited_date().'</span></p>';
} else {
return '';
};
}
The function you see called in the condition are WordPress core functions. =)
I'm very new at wordpress and I'm trying to understand a code from a friend. I went to his wordpress account and edit some test page. However, the page has code inside [ ] tags. How can I edit it?
Here is an example from the wordpress wdit page:
<p style="text-align: center;"><strong>Test- #1 Business Communication App For Project Management & Task Management</strong></p>
<strong>Important Notice:</strong> If you accessed ....</strong></em>, in order for your account to be properly updated.
[register_form]
How can I open/edit the [register_form] code?
This is a shortcode from a plugin or from your theme.
Edit
You can edit it in your theme. If the shortcode is from a plugin, you can overwrite it in your functions.php
function say(){
return "Hello World";
}
add_shortcode( 'register_form', 'say' );
are the tags used to call a function of some plugin that you have active. that specific tag I do not recognize what plugin is, I recommend Contact Form 7, it is easy to use.
If you want to create a PHP function and use it on your page, create a plugin and declare the call as you want. But! Be careful as an error however small will damage your page.
for add tag on wordpress, from your plugin.
function NAME_FUNCTION(){...}
add_shortcode( 'NAME_FUNCTION', 'NAME_TAG' );
and call
[NAME_TAG]
This sounds like it should be something simple or there should be a simple shortcode plug in to achieve this but i have searched and searched for almost and hour now and can't find the answer. All i am trying to do is display the post's published date in the body text. Example: [meta = "Date"]. Is there an easy light weight solution to achieve this. I simply need to publish the post date inside the content. Thanks.
There is a good article on how to do this with a custom plugin or snippet of code for your theme
https://krogsgard.com/2012/create-a-shortcode-to-show-when-a-post-was-last-updated/
You can create a shortcode easily within WordPress. This is a sample of code that you can either place in a new plugin file. For creating a plugin file, visit https://codex.wordpress.org/Writing_a_Plugin , basically, you create a file, lets say my_shortcodes.php and place it in the /wp-content/plugins/ folder. In that file, you would have the following.
<?php
/*
Plugin Name: My Plugin Stuff
Plugin URI: http://domain.com/
Description: My Plugin Stuff
Version: 0.1.0
Author: Your Name
Author URI: http://your-website.com/
License: GPLv2 or later
*/
function shortcode_post_published_date(){
return get_the_date();
}
add_shortcode( 'post_published', 'shortcode_post_published_date' );
Then you would use the shortcode in your post [post_published]
Disclaimer:
This is a sample of what it may look like. You may have to make some modifications to it to make it work the way you want. You may not be able to copy and paste this into your code and it work right away.
I'm testing with very simple code to try and get ajax working from within a plugin I'm writing. However I always get the dreaded 0 returned from the admin-ajax.php file.
The basic code defined in my plugins main php file is:
// Init custom actions
add_action( 'wp_ajax_import_run', 'import_run' );
function import_run() {
echo "testing 123";
die();
}
And then import_run is the action parameter parsed via the jquery ajax call.
Now the funny thing is, this works fine when I place the above php code in the themes main function.php file, but whenever I place the code in the actual plugin where it's needed it won't work. The issue is it needs to be in the plugin, not the theme.
So it seems I'm missing some small vital step about where to put my add action and function within the plugin. Any ideas?
you haven't provided your complete code in your plugin.
You can't invoke plugin function using wp ajax call.
Here's a simple WP plugin code to display some text everywhere.
<?php
/**
* #package Testplugin
*/
/*
Plugin Name: Testplugin
Plugin URI: someuri
Description: To demo a simple plugin
Version: 2.5.8
Author: Automattic
Author URI: http://automattic.com/wordpress-plugins/
License: GPLv2 or later
*/
function pluginnamehere() {
echo "This gets displayed everywhere";
}
add_action( 'plugins_loaded', 'pluginnamehere' );
I've worked out what was going on. I was adding the add_action hook everywhere but in the core root plugin page. Previously I had been adding it to a secondary php file that I thought was the root plugin file but wasn't.
The confusion occurred because I'm using a boilerplate empty plugin template to work with, so even though the plugin does very little so far its actually full of code and remarks already.
I want my WordPress blog to have a page called music. On that page I will query the DB for posts with the category music and then change around the look and feel of the posts. So I can't just put a link to /categories/music/ because I want to do custom work on the posts.
Should I put this code in a separate php file and link to it? I think I may lose access to all the nice WordPress API calls if I do that.
I was thinking about using a filter, but I am not sure which one to use. I was thinking something like the following except the_title has not been grabbed yet so I cannot check the title.
function show_music(){
if( is_page() && the_title('','',false) == 'music' ){
echo "got here";
}
}
add_filter('pre_get_posts', 'show_portfolio');
How would you go about this?
You need to put the below code in the file, and then put the file in the Theme folder. Then you can create a page using Wordpress pages and select a page template with the name you put in this comment:
/*
Template Name: Something Goes Here
*/
You need to create custom page within your theme. If you dont have idea how to create custme page or template page in WordPress theme then view my easy tutorial How to create template page in WordPress