I have a simple HTML page and I need to hide a little part of the text from Google.
<p> text i want to hide </p>
I could load this text with php include and use a robots.txt but the problem is - if someone would set a link to this php file - Google would again show the text I want to hide.
My next idea was:
$str = 'textiwanttohide';
echo base64_decode($str);
but the problem is - Google encodes this within seconds and the text is shown in the Google results.
So how can I hide a specific part of my text from Google? Is there a php or javascript solution?
the proper way is:
indexed
<!--googleoff: all--> not indexed <!--googleon: all>
See Excluding Unwanted Text from the Index for details.
You could store the text in a database like MySQL and load it dynamically with jquery and Ajax. So I think Google shouldn't find this text.
Related
I have stored rich text in my db, and now I would like to show it to the website viewers, but when I echo the content I got this:
<p>sometext</p><strong>text</strong>
I would like to remove the 'P' tags and any other tags from the text.
I have used Ckeditor to store the rich text into DB.
I could use Ckeditor to show the rich text to the website viewers, but Ckeditor is an editor and I would like only to show the rich text.
Is there any in-built php command to convert the stored text into rich text and display it on my website?
Well "rich text" is has its own format. It's not xml like. So for example, a simple file where I will try to infer formatting of:
Hello
This is bold
This italic
Looks like this in "rich text":
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 Hello\par
\b This is bold\b0\par
\i This italic\i0\par
\par
}
So it is not so simple to get this into HTML.
I'ts straight forward on steps to get it into html (some text parsing involved, and a loop) but from your question it doesnt seem like you are (1) aware of it's format, and (2) haven't tried to write code to make it html?
I can add to this answer if you have actually tried on how the parsing steps might go. I can add now but want to get more information so as not to provide useless code, say if you are already using an API that does the deed.
I use Draft.js with React.js but I hope this helps. if you're still facing this issue: You can see the solution in this video
Basically you have to convertToRaw, then JSON.stringify it. Then this can be sent to your backend as a string. To display it, make a GET request for that particular data, then JSON.parse it and then convertFromRaw. Pass this into another RichTextEditor as the editorState but set the readOnly={true}
Find the methods for your particular editor which allows you to convert states and display it.
I want to edit the content of a custom post type in WordPress.
I am able to edit the shown text by this line of code in javacript.
// $('#wp-content-editor-container textarea.wp-editor-area').append("\n some text to add in editor");
However, if I start editing this text on editor I am no longer able to edit it by javascript.
I know that WordPress is using TinyMCE but I do not know how to get the id of the tinyMCE for the editor that is used in post content.
Please help me find the best solution.
what exactly you want to edit in content?
If you want to add certain common text below each post content than you can achieve it using
wp_content filter
https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content
I found that the custom post type that I was using does not use TinyMCE and I edited the content of my editor just like this.
// $('#wp-content-editor-container textarea.wp-editor-area').append("\n some text to add in editor");
with this differences:
$('#content').val($('#content').val()+"\n\n some text to add in editor");
Actually, I was mistakenly using append method instead of adding to the textarea value.
Thank you by the way for your quick reply. My new friend.
Swapnil Ghone
When you select some elements on the webpage by mouse and then paste it in new email (for example in gmail) you still see html elements. But when I add html code to clipboard from js I still see html code after pasting. Is there any way to add some html code from js and see generated elements after pasting?
That is not possible because of the way gmail handles this (the right way). Just imagine if you were able to send javascript tags to anyone with codes that would send cookie info back to you. This is called escaping html and google (and everyone else who does it does it right). Cheers
I am using CodeIgniter for my own web page and I have several textareas in it. Is there any way that I can prevent HTML tags to be stored in the database? Is there any utility that takes the text out clean?
Also, I do want to display line breaks, so when anyone types anything in the textarea and presses enter, it should produce a line break when displayed later. Should I store the <br> in the database?
I don't know if this can be done with CodeIgniter or any php function or javascript and/or jQuery has to be used, and how to do it.
Make use of strip_tags for this... with an allowable tag <br> selected.
$text = strip_tags($htmltext,'<br>');// <br> is an allowed tag , others will be stripped off..
Use the php function strip tags: http://www.php.net/strip_tags
I would like to add 'span' tag on the beginning and '/span' on the end of each line of text as it is presented in the website and change it dynamically when a div containing such text is resized. The problem is that I don't know how to detect where the text is being wrapped - if I had such information it would be easy. So my question is: is there a way to determine where the text is wrapped using javascript?
I have found a javascript library which hyphenates the text in the site but I'm not sure how does it detect line wraps. The working example is here and it's source can be found here.
yes, this is like to Search For and Highlight Text.
using javascript you can learn it here:
Search For and Highlight Text
or here:
how-can-i-use-jquery-to-style-parts-of-all-instances-of-a-specific-word
just download/save the web page there and you can learn it.