0

I want to make an email-signature page with Elementor and then generate the HTML-code like the code when you that appears when you "View Source" of a page, but code gets not exactly correct. I am using a Custom post type and a Elementor template that is not published so it works only when writing: https://mysite123123.com/a/site/?theme_template_id=1164

I have a PHP snippet plugin and this code gets the Post type HTML but not the same like when you press rightclick/View Source. (Its missing some css etc)

Can you see what Im doing wrong or if you know how to echo the correct html from a webpage like a regular visitor see it?

(Im using this code to give a user a HTML signature)

<?php
global $wp;
$vpost = get_post($post_id);
$urlcard = $vpost->post_name;
$current_url =  home_url( $wp->request );

$data = file_get_contents("https://mysite123123.com/a/".$urlcard."/?theme_template_id=1164");
$html_encoded = htmlentities($data);
echo $html_encoded;
Omi in a hellcat
  • 558
  • 1
  • 8
  • 29
codesid
  • 21

1 Answers1

0

You can tell the browser how it should render your data using a Content-Type HTTP Response header.

To have your data rendered as plain text -- as the 'View source' view does -- use "text/plain" as mime-type;

header("Content-Type: text/plain");
echo $data
Ferdy Pruis
  • 1,073
  • 8
  • 9