E
E
Emperio2015-10-02 12:18:44
WordPress
Emperio, 2015-10-02 12:18:44

Why are wordpress plugin shortcodes not working in my theme?

I am writing my theme based on this picture: https://developer.wordpress.org/files/2014/10/temp...
After installing and activating plugins "for login and registration" (theme my login, wp-recall), some pages on which only the shortcode itself is written (for example [theme-my-login] )
For some reason I have nothing on these pages - a blank sheet. Those. shortcodes don't work. Installing plugins on the twentyfifteen theme shows that the plugins are working and the shortcodes there work and the pages that appear after installing the plugins are not empty.
Obviously the problem is in my theme. I see a white sheet both on the local server and on the server of the hosting provider. My theme has the following files: 404.php, category.php, footer.php, footer-home.php, functions.php, a bunch of headers - each page has its own, home.php, index.php (empty), a bunch of files like page-id.php, search.php, searchform.php, sidebar.php, single.php, single-post.php. Well, another style file and a screenshot. Here is the functions.php code:
function load_scripts(){
wp_enqueue_style('style', get_bloginfo('template_url').'/style.css' );
wp_register_script('main', get_bloginfo('template_url').'/js/main.js',false,'26092015' ,true);
wp_enqueue_script('main');
}
add_action('wp_enqueue_scripts', '
add_theme_support( 'post-thumbnails' );
register_nav_menu('nav_menu', 'Navigation header menu');
/*if (function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
)); */
if (!current_user_can('administrator')):
show_admin_bar(false);
endif;
register_sidebar(array(
'name' => 'Sidebar Widgets1',
'id' => 'sidebar1',
'description' => 'login'
));
));
register_sidebar(array(
'name' => 'Sidebar3 widgets',
'id' => 'sidebar3',
'description' => 'for categories'
));
function mytheme_content_filter( $content ) {
// Do stuff to $content, which contains the_content()
// Then return it
return $content;
}
add_filter( 'the_content', 'mytheme_content_filter' );
add_action('phpmailer_init','send_smtp_email');
function send_smtp_email( $phpmailer ) {
// standard mail settings code here
}
if ( ! function_exists( 'get_current_page_url'
return add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $wp->request ) );
}
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mr Crabbz, 2015-10-02
@Emperio

Get used to pasting such code somewhere on codeshare.io or jsfiddle.com or codepen.io
In fact:
You have some sort of the_content() filtering function here:

function mytheme_content_filter( $content ) {
// Do stuff to $content, which contains the_content()
// Then return it
return $content;
}
add_filter( 'the_content', 'mytheme_content_filter' );

Obviously, somewhere in the theme, when displaying page content, it cuts off your shortcode.
If you do not find the reason - you can use such a crutch:
Here you create your own login page with the slug my-login, then clone your page.php with the name page-my-login.php. In it, find a piece of code where the_content or $content is displayed and replace it with this:
<?php echo do_shortcode("[theme-my-login]");?>

E
Emperio, 2015-10-02
@Emperio

For those who may come across this question, the answer is that having a shortcode in the content of a page is not enough to display anything when clicking on that page's anchor link. You still need the corresponding php file. For example page-simplepage.php which will display the content of the page. For example, in the WordPress cycle using the_content function ( wp-kama.ru/function/the_content)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question