I have a problem where custom theme does not load plugins files on custom theme page.
When switching to default theme plugins files get loaded correctly on the same page.
I am not sure if I am missing something as all action hooks that I could find mandatory are included.
Any guidance or help will be much appreciated, thanks.
Custom theme page setup is as follows:
header.php contents:
<!doctype html>
<html lang="en-US">
<head>
<?php wp_head();?>
</head>
page-custom.php contents:
<?php get_header(); ?>
<body>
<?php
// content
$content_post = get_post(125); // 125 equals id of the custom page
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
// footer
get_footer();
?>
footer.php contents:
<?php
wp_footer();
?>
</body>
</html>
I would look through the plugin's code to see what it's actually hooking into and figuring out if it's something missing from the template your theme is loading on a certain page.
Related
I have been researching a problem that I have and came across this discussion:
https://gtranslate.io/forum/how-not-translate-the-title-meta-tag-t4852.html
In there the answer provided is to use this html syntax:
<title class="notranslate">Example</title>
The issue at hand is to prevent Google Translate from translating the <title> tag. What I have is a WordPress website:
www.publictalksoftware.co.uk
I don't know how to go about changing the site to apply this syntax for all the <title> tags on my posts and pages. I read up about wp_head() but am getting lost.
Any advice appreciated.
Update
The header.php for the theme I am using has this code:
<?php wp_head(); ?>
<?php if ( get_option('google_analitic_code') ) : ?>
<?php echo get_option('google_analitic_code'); ?>
<?php endif; ?>
</head>
Add Below function in function.php
remove_action( 'wp_head', '_wp_render_title_tag', 1 );
Add Below code in header.php befode wp_head();
<title class="notranslate"><?php bloginfo('name');?> | <?php wp_title();?></title>
Hope this works for you.
I'd like to be able to edit my WordPress theme's CSS by using a Page in the backend instead of the default style.css file. I've seen it done before as a page template but I can't seem to figure it out myself.
I'm using WordPress version 4.7.2 on a Multisite. I want the CSS to generate on theme activation, hence using a Page.
I apologize in advance if this is an easy fix and open to other ways to accomplish this. Thanks!
I highly recommend using a plugin, such as https://wordpress.org/plugins/wp-add-custom-css/ or use the WordPress Customizer "Additional CSS" field.
However, to answer your question, this was easy since it's a modified way that I make some pages I load with ajax. You will need to create a page template and that requires FTP and a code editor to create the page and then push it your theme folder (hopefully a child theme or this template will go away when you upgrade).
I named my CSS page template: css-page.php
It requires only the opening php tag.
CODE for template css-page.php
<?php
/**
*
* Template Name: CSS page
* Not a recommended idea.
*
*/
header("Content-type: text/css; charset: UTF-8");
ob_start("compress");
//minify CSS
function compress( $minify ) {
/* remove comments */
$minify = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $minify );
/* remove tabs, spaces, newlines, etc. */
$minify = str_replace( array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $minify );
return $minify;
}
//get the content
if (have_posts()) :
while ( have_posts() ) : the_post();
$content = get_the_content();
$content = wp_filter_nohtml_kses( $content );
echo $content;
endwhile;
endif;
ob_end_flush();
Then in your functions.php file in your child theme (or an include of that file or a custom plugin) paste in the following BUT change it where noted:
Change the value p='3134' to your page id where you're using this template. Change the id="something" to something else or remove it. Useful to have an id or a class for js manipulation.
For functions.php
//Get CSS page contents
function myprefix_page_css() {
echo '<link rel="stylesheet" id="something" href="'. site_url() .'/?p=3134" type="text/css" media="screen">';
}
add_action( 'wp_head', 'myprefix_page_css', 99 );
I have wordpress site and I'm using this script
onclick="<?php if(!isset($_COOKIE['visited'])){echo"window.open('http://link', '_blank')"; setcookie("visited", "1", time()+3600*24); header("Refresh:0");} ?>"
in body line. So it means I'm using
<body <?php body_class(); ?> onclick="<?php if(!isset($_COOKIE['visited'])){echo"window.open('http://link', '_blank')"; setcookie("visited", "1", time()+3600*24); header("Refresh:0");} ?>">
on header.php file of the theme.
But it opens the link in every click.
I want to open it only one time until I refresh the page or open new page.
How can I do it.
Please help.
Thanks in advance.
Greetings.
Like the setcookie function reference says:
cookies must be sent before any output from your script
First solution
You could add this at the very top oh header.php:
<?php
$onclick = '';
if(!isset($_COOKIE['visited'])) {
setcookie('visited', '1', time()+3600*24, COOKIEPATH, COOKIE_DOMAIN);
$onclick = 'onclick="window.open(\'http://link\', \'_blank\')"';
}
?>
Update: I've added the constants COOKIEPATH and COOKIE_DOMAIN like explained here.
And this for your body tag:
<body <?php body_class(); ?> <?php echo $onclick; ?>>
Better solution
The prior solution doesn't ensure the cookie is set before any output sent (there could be some characters in one of you template files before get_header() is called, or a plugin could add something).
Instead you should add an action to a Wordpress hook that is always called before any output (like init).
So try adding to your functions.php file:
add_action('init', 'set_visited_cookie');
function set_visited_cookie() {
if (!isset($_COOKIE['visited'])) {
setcookie('visited', '1', strtotime('+1 day'), COOKIEPATH, COOKIE_DOMAIN);
}
}
As for your body tag:
<body <?php body_class(); ?> <?php if(!isset($_COOKIE['visited'])): ?> onclick="window.open('http://link', '_blank')" <?php endif; ?>>
I followed this guide to have my blog appear under mydomain.com/blog:
http://codex.wordpress.org/Making_Your_Blog_Appear_in_a_Non-Root_Folder
In short, I'm using a custom page template to create a static page "Blog", which then goes and renders the posts:
<?php
/*
Template Name: Blog
*/
// Which page of the blog are we on?
$paged = get_query_var('paged');
query_posts('cat=-0&paged='.$paged);
// make posts print only the first part with a link to rest of the post.
global $more;
$more = 0;
//load index to show blog
load_template(TEMPLATEPATH . '/index.php');
?>
In my theme, I render the <title> tag using the following syntax:
<title><?php bloginfo('name'); ?> | <?php is_front_page() ? bloginfo('description') : wp_title(''); ?></title>
This is described here in the codex:
http://codex.wordpress.org/Function_Reference/wp_title#Covering_Homepage
The problem is that now on mydomain.com/blog, there is no title rendered by wp_title('');
If I stop using the blog.php template, then the title appears correctly. Obviously the blog posts do not anymore though. How to have the wp_title() display the correct title in this situation?
You should be following the updated guide for Wordpress 2.1+:
http://codex.wordpress.org/Creating_a_Static_Front_Page
Just changed themes with drupal and I'm left with white screen of death. Default theme which worked was Zen. This is stored under sites/mysite.com/themes
Theme I changed to I think is one of the themes under themes/
Don't have access to the database. Have FTP access.
Is there any way to change themes or install one that will work?
The easiest way to correct your problem is to find what's wrong.
go to index.php and add the following lines after <?php
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
Then post the error here.
Don't forget to comment/remove when you're done.
EDIT:
If I understood correctly this was what you did before going WSOD.
You were using Zen theme.
You logged into your site with administrator privileges and went to http://yoursite.com/admin
You went to the theme management and changed your theme to another one (henceforth refered as "theme_b")
When refreshed the page (or went to another page in your site) you got the WSOD.
.
If this is true then follow these steps:
Create a blank theme.
In order to do this, create a folder in your computer named "theme_b".
Inside create the following files:
theme_b.info, template.php, style.css and page.tpl.php
Open theme_b.info and paste this:
name = theme_b
description = bla
version = 1
core = 6.x
engine = phptemplate
stylesheets[all][] = style.css
Save.
Open page.tpl.php and paste this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<?php print $head ?>
<title><?php print $head_title ?></title>
<?php print $styles ?>
<?php print $scripts ?>
</head>
<body>
<div><?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?></div>
<div><?php print theme('links', $secondary_links, array('class' => 'links secondary-links')) ?></div>
<div id="sidebar-left" class="sidebar"><?php print $left ?></div>
<div>
<?php if ($tabs): print '<div id="tabs-wrapper" class="clear-block">'; endif; ?>
<?php if ($title): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif; ?>
<?php if ($tabs): print '<ul class="tabs primary">'. $tabs .'</ul></div>'; endif; ?>
<?php if ($tabs2): print '<ul class="tabs secondary">'. $tabs2 .'</ul>'; endif; ?>
<?php if ($show_messages && $messages): print $messages; endif; ?>
<?php print $help; ?>
</div>
<div>
<?php print $content; ?>
</div>
</body>
</html>
Save.
Then upload the folder theme_a to sites/yoursite.com/themes replacing existing theme_a folder.
This should enable you to access admin section of drupal.
You won't necessarily see any errors. For me it was a caching issue which stopped the page from loading the right content.
I cleared the cache by inserting the following on the last line of my index.php file (in Drupal root). This solved the issue for me:
db_query("DELETE FROM {cache};");
Remember to remove the line again afterwards.
More information about caching, look here: https://drupal.org/node/42055
It's most probably a PHP silent death because there's not enough memory allocated to scripts in /etc/php.ini
On shared hosting environments, you MAY be able to override this using a .htaccess file.
You more than likely have a PHP error that isn't being shown because error reporting is turned off by default on your host. The easiest way to remedy this is to add the following code at the top of index.php:
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
Additionally, you definitely want to locate your php error logs and see if there is any additional information regarding the error there.
Checkout the Drupal help page for this topic: http://drupal.org/node/158043