0

I am trying to create a shortcode from a page that currently resides in the back end. The page has several acf fields as part of a form that creates a request. I would now like to have the same page on the front end. I have tried following the syntax of creating a shortcode from a function after reading about shortocdes, its api and doc and several different tuts online.

add_shortcode('create_requests', array($this, 'load_custom_wp_admin_style'));

^ The attempt above didn't work and I don't get any output when I include the shortcode in a new page.

You can notice that the function I am trying to use 'load_custom_wp_admin_style' returns a null value and uses hooks.

This is the file that contains the function.

R1ddler
  • 47
  • 10

2 Answers2

0

Try to include file like below code. I checked your file according to me you need use the plugin url it seems like you are developing the plugin

wp_register_style('your_namespace', plugins_url('style.css',__FILE__ ));
wp_enqueue_style('your_namespace');
wp_register_script( 'your_namespace', plugins_url('your_script.js',__FILE__ ));
wp_enqueue_script('your_namespace');
Akshay Shah
  • 3,391
  • 2
  • 20
  • 33
  • I don't think that is the issue. The page works just fine in wp-admin on the backend. What I'm failing to accomplish is create a shortcode and include it in a new wordpress page. – R1ddler Sep 21 '17 at 09:54
0

Assuming that the page you want to display on the front end is a normal WordPress page - created in the pages tab, post type page.

Very simply you can just use the following PHP code to include it in a template:

<?php
$page = get_post(192994);
echo $page->post_content;
?>

If it needs to be a shortcode you can add this into your functions.php:

function output_page_function($atts) {
    $page_id = $atts['page_id'];

    if (!$page_id) return false;

    $page = get_post($page_id);

    return $page->post_content;
}
add_shortcode('output_page', 'output_page_function');

And include a shortcode where desired (with 'page_id' attribute)

[output_page page_id=192994]

If it's not a WordPress page, but an actual wp-admin screen, then this would be significantly more difficult/not possible.

M Hayward
  • 126
  • 1
  • 4