I've a wordpress blog directly hosted from wordpress and I use the [code] tags to post sourcecode on wordpress, that works fine so far.
Thats the original code tag I posted
[code language="xml"]
<TypeScriptTarget>ES5</TypeScriptTarget>
[/code]
But when I try to edit my posts with contained sourcecode it looks like this
and when I update my post the same not encoded symbols are shown on my blogpost too. Id don't know what I am doing wrong here.
First, you want to make sure the Visual Mode in WordPress is disabled, and only use Text Mode.
Users > Your Profile
Then you don't need to use a WordPress shortcode for adding a preformatted code block.
Check out the WordPress Codex Writing Code in Your Posts page:
https://codex.wordpress.org/Writing_Code_in_Your_Posts
Just use the HTML <pre> and <code> HTML tags:
<pre><code>
<TypeScriptTarget>ES5</TypeScriptTarget>
</pre></code>
You will notice I am using the HTML entity for the greater and less than symbols so they render correctly on the front-end of WordPress.
< = <
> = >
Resource links to the <pre> and <code> elements:
<pre> tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre
code tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code
Related
I have a wordpress site where there is a <br> appearing right after the first body tag that's causing the entire site to have a line space at the top of the page.
I manually looked at the header.php code and there is nothing between the body tag and the opening Google Tag Manager comment. When loading the site, however, something is inserting application/ld+json script code for SEO and I'm assuming along with the <br>, so my suspicion is it's caused by the Yoast SEO plugin. I'm trying to look at the plugin files for code where it's inserting this script code, but I can't seem to find anything.
This is what the header.php code looks like when editting it in the Wordpress editor:
This is what the header.php code looks like after loading the Wordpress site in a browser:
Does anyone have any clue why or where the is being inserted from?
Thanks!
Just as I posted this question, I found the ld+json script code above the body tag code in header.php that had a <br/> before it. I removed it and it fixed the issue.
My question is about Tinymce Template Plugin.
I have been developing a CMS with ASP.NET MVC. I can insert a template by using “insert template plugin”, but I can not insert a css file.
The template I will insert should be more developed. When I add a css file, it does not work. For example, <link rel=“stylesheet” type=“text/css” href=“theme.css”>. This link is my template I want to use.
And then I am saving this content into my database. This link can not be saved into my database. It can not be seen.
I used content_css ,the template looks good in the editor, but when I look at the page, it looks very bad because the css files does not work. In addition to all of these, when I look at the table of database (column : content) there are not css links (<link href...)
What should I do for this problem ? Thanks for your help.
CSS links belong in the head of the document, it is not valid HTML to add the link tag to the body. The Template Plugin allows you to add fairly involved HTML to the HTML body so you don't have to build that chunk of HTML over and over again. Please read the documentation for Templates: https://www.tiny.cloud/docs/plugins/template/
When you apply CSS in content_CSS it only affects how TinyMCE looks in the iFrame that the editor lives in. You need to get the CSS into the head of the page you are bringing over from your databse.
I have written the following HTML into the text editor of a WordPress post:
<code class="language-javascript">jsonFile.image</code>
When I preview the page, I get this:
<code>jsonFile.image</code>
I have other blocks like this one:
<pre class="line-numbers"><code class="language-json">{
"image": "image.jpg",
"_image_comment": "This image should not be displayed"
}</code></pre>
These are left intact when the post is previewed.
Is this happening because of my theme, or is this something WordPress Core is doing?
The markdown feature of the Jetpack plugin was causing the classes to be dropped when I saved the post. Not clear why it was affecting some and not others, but it was definitely the issue.
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.
I've got a script to post some data to wordpress using xmlrpc.
If I use a simple string for the body like "This is a test" it works fine.
However, if it has any HTML formatting in it, it gets horribly mangled when trying to add the post.
How do I post html content to wordpress with xmlrpc?
Here's a plugin that fixes a problem with some versions of an xml library that strips html: Plugin – LibXML2 Fix | Joseph Scott