i made a couple of php pages and integrated them into wordpress.
The first page is fine, but the second one show "page not found" on the title when it is loaded.
You can find the first page here:
http://www.stefanovirgulti.it/spese.php
then click on "Aggiungi Negozio" to go to second page.
code of first page:
(suppressed wordpress template code)
//if ( is_user_logged_in() ){
if ( true ){
$index=linkBuilder("Aggiungi Negozio",$_SERVER['PHP_SELF']."?p=1");
$appPath="./moneym/";
//$page=$_GET["p"];
switch ($_GET["p"])
{
case 1:
$page="negozi.php";
break;
default:
echo "this is the first page<br>";
echo $index;
break;
}
if ($page != "") include $appPath.$page;
}
else {
echo "This is a private page.<br>";
}
function linkBuilder($name,$path){
return sprintf("%s ",$path,$name);
}
(suppressed wordpress template code)
The code of the second page contains only an echo.
How do i fix this?
PS: the second page works, but if you check the title page, it says "page not found" and i can't change that, this is my problem.
How did you create these pages? Without looking at your header.php file I'll assume your using some sort of default code to get the page title. To create new pages in wordpress you need to create them in the backend admin panel. if your just loading in files, the wordpress enviroment will see this as a page that doesn't exist.
Solved!
I found the "page custom template" functionality. I just made a template with all my code, then used it as template for a wp static page.
I have done the custom template starting from page.php of my current template, took off the code that handles the content, and replace it with my php/sql stuff.
I have made a new page inside wp and used this custom template.
In this way i have a page that does what i want, but act as a real wp page, i can even add it to menus and apply whatever plugin to it. I left the title funcionality so i can change the title of my cutom page from wp admin.
THe reason for this is that one of your included phps includes a check for wordpress environment and displays that title when the condition is satisfied.
The solution is to use php to output "" tags before the included file is loaded.
Related
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.
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');
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.
this is how I'm going with wordpress forum
it is such that even if you do not log into the site you can see what you can create, etc.
Create forum / post to the site just being tucked away so it is only possible to view it if you are login on the page.
Comment content must also be away but just get some text that you can not write content until he has sustained itself on the page.
I purchased this forum
http://themeforest.net/item/forumengine-flat-responsive-wordpress-forum-theme/5999646
WordPress comes with all the functionality needed for this its as simple as wrapping the content you want within an if statement for example
<?php if ( is_user_logged_in() ) {
echo "Member Content";
}else{
echo "Sorry Guest";
?>
id suggest something like above if you are working with template files you could always wrap the while loop with the above
I am relatively unfamiliar with Wordpress and I am creating a custom theme for a client. I would like to either display or remove the main menu depending on the page type. I have researched several options like removing the navigation from header.php and referencing it separately and also making the menu conditional which is preferable.
I have a custom page type in my theme called 'landing page' on which I would like the menu to be never be displayed, though it will be on every other page. Ultimately there will be a lot of these and I would rather I didn't have to intervene.
I would rather not duplicate my header.php file but I can only find reference to displaying the menu conditionally like below by page name or ID which seems ridiculous.
<?php
if (is_page('contact')){
<?php include(TEMPLATEPATH.'/headerA.php'); ?>
}
elseif (is_page('gallery')){
<?php include(TEMPLATEPATH.'/headerB.php'); ?>
}
else {
<?php include(TEMPLATEPATH.'/headerA.php'); ?>
}
?>
Rather than including files as above, I will put the whole thing into my header and just make the navigation conditional. Does anyone know how I should approach this using my custom page type landing page rather than by page name so every page created with that type will never have a menu?
Thanks
Are you talking about a Custom Post Type (CPT) or a page called landing-page?
They are completely different. See http://codex.wordpress.org/Post_Types
In any event, this will work for a custom post type or a page:
if ( !is_singular( 'custom-post-type-name-or-page-slug-here' ) ) {
get_template_part('menu');
}
It says: "If this page is not a single page or a CPT, load the file menu.php from the theme folder."
See also http://codex.wordpress.org/Include_Tags:
The get_template_part() tag includes the file {slug}.php or
{slug}-{name}.php from your current theme's directory, a custom
Include Tags other than header, sidebar, footer.
i am using joomla 3 for a web site, i don't use any content in the main page but the system output is on because i need to output contents on other pages of the site. the problem is i have a space in the middle of the page where normally the content comes. i know where this comes from but i have to disable it if there is no content on that selected page. i tried to check the
$this['template']->render('content')
which is actually used to render the specific content. but i was not able to use it in a conditional if. so i need to check if the loaded page has a content output. has anybody a idea how i could do that?
PS: i dont want do this with css.
You may check if you are showing the main page and render conditionally:
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
$this['template']->render('content');
}
?>
For multilingual site check this link for detecting if you are on the default page:
http://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page
Just curious... why don't use the <jdoc:type="component/>?
Ok I have some custom Omniture code I need to add to a Drupal site. All is good as I have added the Javascript code to the themes template page. The code shows up on all the pages as expected but I have a couple of PHP variables that I need to print in the Javascript that are coming up blank.
<?php
$omniture_event = "test this works as expected";
$omniture =<<<OMNITURE
<script language="JavaScript"><!--
s.events="{$omniture_event}"
s.landing="{$omniture_landing}"
OMNITURE;
echo $omniture;
?>
but $omniture_landing is set on the landing page only and it looks like the template page is being loaded first then the content of the page is being added. I can print the value to the screen and I see the Javascript in the footer as expected with the other PHP variable set, but when I try to set the variable on the landing page it comes up blank in the javascript.
You can edit your page.tpl.php template file. If the 'Landing page' is your front page, then you can do something a little easier and more consistent (if you end up changing the title).
if($is_front) {
$omniture_landing = 'Yeah we have landed!!!';
}
Or by node id:
if($node->nid == '1') {
$omniture_landing = 'Yeah we have landed!!!';
}
Replacing 1 with whatever the node Id is of course
Also, check to see if you have a page-front.tpl.php If so, that file, page-front.tpl.php is the template that runs on the landing page instead of page.tpl.php and you can add your code to page-front.tpl.php or remove it if you don't need a separate template for the landing page.
I ended up adding this to the template page (page.tpl.php) before the Omniture code
if($node->title == 'Landing Page Title') {
$omniture_landing = 'Yeah we have landed!!!';
} else {
$omniture_landing = '';
}