Wordpress - Having head, body into WYSIWYG editor - html

I created my event pages with a different website. That website generated an html page for me(with Javascript, CSS hosted at their end) each time I created an event. I would like to embed the event pages into my website. In order to achieve, I tried to create a blank page template like below:
<?php
/**
* Template Name: Blank
*
*/
if (have_posts()) {
while (have_posts()) { the_post();
the_content();
}
}
?>
Then pasted the content (including head and body) into WYSIWYG editor. However, WordPress pushes everything into body. How can I create a pure blank page template and have the ability to edit everything with WYSIWYG?

Not quite sure if this is the best way to solve your problem. If I understand correctly you want to include events from website X in a page on website Y?
Assuming you set up events as a custom post type, you could use an 'event' RSS feed on website X: http://www.website-x/feed/?post_type=event
Then, on website Y reed the feed using:
$content = file_get_contents('http://www.wesite-x/feed/?post_type=event');
$x = new SimpleXmlElement($content);
foreach($x->channel->item as $entry)
{
$title = $entry->title;
//ETC...
}
It's not wysiwyg but it well get you all the content you need, and you can do whatever you want with it.
Hope this helps.

Related

Changing specific word in Site Title WordPress

how do I change the color of a specific word in the site title in Wordpress. I have been trying to figure this out for a whole day already. Please helpp!!!
If the website is a website that you made in made in wordpress.com, there is no way to do so.
If you are using wordpress.org software, that is wordpress on a custom hosted website, then you can do this by finding the title from the template(it will be a php function call or variable) and then replace it with the title as plain text and apply whatever CSS you need.
(Note that the title will not change if you update it from within wordpress CMS after you do this. Also changing template will undo this )
add_filter( 'bloginfo', function( $output, $show ) {
static $count = 0;
if ( $show === 'name' && $count++ === 1 ) {
$output = 'your <span style="color:red;">new</span> site title';
}
return $output;
}, 10, 2 );
UPDATE:
I tested this and it does work on theme Twenty Seventeen but does not work on another theme. As the site header is done by the theme a theme can really do anything it wants. This will work if the theme is using the conventional WordPress bloginfo() function to do the site title.
UPDATE2:
Unfortunately, bloginfo() is also used to generate the HTML title element where you do not want embedded HTML tags. In theme 2017 I can avoid this by only overriding bloginfo() on its second call to 'name'.
This is a very ugly solution and I would recommend either using a child theme or dynamically rewriting the title using JavaScript.

Remove Top bar/header/Main Nav links from one page

I am creating a landing page and I would like to remove the topbar and header/main Nav links from this page, and this page only.
Currently, I use this CSS code to remove it:
.top-headers-wrapper{display:none;}
However, it leaves a big blank white space in place of the header. Ideally this white space would be removed and the big background image would go all the way to the top of the page.
I illustrate the difference below, where the page with -test appended to the URL has the CSS to remove the header. The original URL does not have the code to remove the header.
How can I modify the code to remove this white space as well as the header/topbar?
https://www.californiabeardco.com/summer-giveaway/
https://www.californiabeardco.com/summer-giveaway-test/
Your content-area class has a top-margin of 133px. If you are removing the header altogther then you should be able to remove the top margin like this
#page_wrapper.transparent_header .content-area {
top-margin: 0;
}
It looks like there are a couple of instances of this in the various #media queries in the CSS file. So you will have to find each instance.
Also like Obsidian mentions in the comments when I access your site I was logged in with admin privileges, you should change this as soon as possible. Hope that helps.
You should disable admin bar by more elegant way, like go to Profile > uncheck the options Show Toolbar when viewing site.
Or if you want to completely disable admin bar for all logged in users, insert this code to your theme's functions.php file.
function remove_admin_login_header() {
remove_action('wp_head', '_admin_bar_bump_cb');
}
add_action('get_header', 'remove_admin_login_header');
Another way is use filter, completely disable for all logged in users too.
add_filter( 'show_admin_bar', '__return_false' );
Ultimately, I found a solution. It's a bit of a workaround but it worked nonetheless.
The solution I found was to create a page template (e.g., "Landing Page") with no headers, footers, or sidebar. This results in a blank page which, when using a page designer like Visual Composer, allows me to design on a blank canvas, perfect for creating a landing page.
I followed the steps from this tutorial but will post them here for anyone else with the problem:
1) create a new php file
2) paste in this code
<?php
/**
* Template Name: Clean Page
* This template will only display the content you entered in the page editor
*/
?>
<html <?php language_attributes(); ?> class="no-js">
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php wp_head(); ?>
</head>
<body>
<?php
while ( have_posts() ) : the_post();
the_content();
endwhile;
?>
<?php wp_footer(); ?>
</body>
</html>
3) Upload the php file to the server hosting your Wordpress instance. The location should be your theme directory. Something such as ../wp-content/themes/YourThemeName
I added the php file to my child theme which worked fine, if you use a child theme, which is usually recommended protocol as I understand it.
4) Log onto the Wordpress admin console and when you create a new page, look for your newly added Template as an option.

How to change the location of the TOC in a MediaWiki skin

I'm woking on a MediaWiki skin for my site. For the page content I'm using <?= $this->html( 'bodycontent' ); ?> to output it all. Part of this, on longer pages, is the Table of Contents (TOC).
I would like to move the location of the TOC out of the body an into the sidebar but I'm not sure how to prevent the TOC from showing in the bodycontent or where to get the raw data to display it in the sidebar.
I'm hoping there is a data time similar to $this->data['sidebar']['navigation'] that I can use to format it how I want.
How can I turn off the TOC in the bodycontent?
Is there a $this->data location that has the TOC data?
The MediaWiki skinning system is not really designed for this, but someone created an extension to make your work easier: https://www.mediawiki.org/wiki/Extension:DeToc
Using that extension you would do something like this (inside function execute()):
$body = $this->data['bodycontent'];
$new_body = DeToc::RemoveToc($body, $extracted_toc);
/* Print body */
echo $new_body;
/* Print TOC somewhere else */
echo $extracted_toc;
Alternatively you could just turn off the TOC, using $parser->mShowToc = false;, and then create the TOC yourself. MediaWiki internally uses a regex like this to find all sections: '/^\={2,5}(.*?)\={2,5}$/m'

Open page as pdf with DOMPDF

I am currently working on a semi dynamic page where I use some GET functionality to personalize it. I also echo the date a couple of places. At the bottom of this page, I would like to have a button that gives the visitor the option to download/open this page as PDF. Without the header. I have integrated DOMPDF, but I simply cant get it to work properly and need some help. I have tried a couple of things found here on Stackoverflow, with no success.
In basic, I need the whole page printed in the PDF, but it should not open when page is loaded. But triggered by the button. And then without the header (one spesific div). Is this possible?
<?php
require_once("dompdf/dompdf_config.inc.php");
$html =
'<html><body>'.
'<p>This is a test for '.
'<?php echo htmlentities(substr(urldecode($_SERVER["QUERY_STRING"]), 1)); ?> </p>'.
'<p>Thank you for reading.</p>'.
'</body></html>';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("the_inquiry.pdf");
return true;
?>
<html>
<body>
<div class="shouldnotPrintToPDF">
Content.
</div>
<div class="shouldPrintToPDF">
Sensitive content.
Open or save as PDF
</div>
</body>
</html>
This is basically our one page presentation. And contains a lot of text, so I will not present all of that here. But in this way, I have to write the page twice, in $html = as well as inside the actual tag. And the PDF save/open option pops up right from the start, which it should not. I also wish to append the echo htmlentities part to the actual pdf-name.. is this possible? The PDF opens and contains what put into the $html = just fine. But not triggered by the link.
Update:
When i do exactly what you perform here, I get an error "The requested URL /inquiry.php&pdf=1 was not found on this server." I have the page I am trying to print in pdf on root level, but the DOMPDF is in /dompdf.. I dont know if that has anything to do with it?
Update:
When i edited the link, i get all this information up in a new page, like below.
[_parse_properties(margin:=1.2cm)(empty)_parse_properties]
[_parse_sections[section[_parse_properties(display:=-dompdf-page)
(counter-reset:=page)(empty)_parse_properties]#html#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]
_parse_sections][_parse_sections[section[_parse_properties(display:=block)
(empty)_parse_properties]#div##map##dt##isindex#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]
_parse_sections][_parse_sections[section[_parse_properties(page-break
-before:=avoid)(display:=block)(counter-increment:=page)
(empty)_parse_properties]#body#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
[_parse_sections[section[_parse_properties(display:=block)(margin:=1em
0)(empty)_parse_properties]#p##dl##multicol#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
[_parse_sections[section[_parse_properties(display:=block)(margin-left:=40px)
(empty)_parse_properties]#dd#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
[_parse_sections[section[_parse_properties(display:=block)(margin:=1em
40px)(empty)_parse_properties]#blockquote#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
[_parse_sections[section[_parse_properties(display:=block)(font-style:=italic)
(empty)_parse_properties]#address#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
[_parse_sections[section[_parse_properties(display:=block)(text-align:=center)
(empty)_parse_properties]#center#section]
Do you have any idea what it might be caused by?
Breakthrough:
When I activated DOMPDF_DPI it actually opens as PDF, but now all of the text comes on first line of the second page of the PDF. Like, all the text comes out on top of each other. Also, when it opens the PDF, the ?&pdf=1 are included in the htmlentities query string, which looks very messy since it is supposed to be a personalized page as well as the PDF.
You can set dompdf to parse CSS #media queries for standard media types (screen, print, voice, etc.). By default dompdf parses the "screen" media type styles, but you can change this in the configuration file. See the DOMPDF_DEFAULT_MEDIA_TYPE configuration setting. Then you just need to pass the original URL querystring with an appended variable telling the page to render to PDF. If your original URL is something like the_inquiry.php?name=Joe then your PDF URL could be the_inquiry.php?name=Joe&pdf=1.
Your code would then look similar to the following:
<?php
ob_start();
?>
<html>
<head>
<style>
#media print {
.shouldnotPrintToPDF, .pdflink { display: none; }
}
</style>
</head>
<body>
<div class="shouldnotPrintToPDF">
Content.
</div>
<div class="shouldPrintToPDF">
Sensitive content.
Open or save as PDF
</div>
</body>
</html>
<?php
if ( isset( $_GET['pdf'] ) ) {
require_once 'dompdf/dompdf_config.inc.php';
$html = ob_get_clean();
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("the_inquiry.pdf");
}
?>

formatting posts in wordpress

I'm developing a wordpress theme, but I'm stuck in formatting the single.php.
I have in my posts a slideshow plugin which is load with the_content() function, togheter with the text of the post, and with the_title() load the title.
that seen like this:
<h1>the_title()</h1>
<div id=post>the_content</div>
the problem is, I need customize how it's display.
I need display:
<div>theplugin</div>
<div id=post>
<span>the_title</span>
the text
</div>
I try to do that with add_filters but I wasn't lucky.
I hope you can understand my explanation, if you need more details, just tell me.
Thanks in advanced.
If users can add plugin components to posts in the editor, they are usually added via shortcodes.
If that's the case with your plugin, you can add it with apply_filters(). Here's an example of how to add a slideshow from the popular nextgen gallery plugin outside the post content:
<?php
$slideshow = apply_filters('the_content', '[slideshow id=1]' );
echo $slideshow;
?>
The above code can be added into single.php, any static page's page template file or directly into header.php to display on all pages.
If you specify the plugin you're using, I'll update the answer accordingly.
If it should indeed be called directly via a function, I second Ancide's answer.
You just need to change the place of where the functions are situated. Like this:
<div>theplugin</div>
<div id=post>
<span><?php the_title(); ?></span>
<?php the_content(); ?>
</div>
Edit: I misunderstood the description of the problem. Here's my answer now that I understand what the problem is:
The plugin uses a hook for the_content function. If you look inside all the php-files inside wp-content/plugins/your-plugin there will be a file with this code:
add_action('the_content','some-function-name');
This tells wordpress to run the function some-function-name everytime the function the_content is run. So you need to look for the some-function-name to figure out how to customize the output.