I am trying to add the "Custom-Background" theme hook for a WordPress site.
In my functions file, the one for the theme folder, I added
add_theme_support( 'Custom Background', array (
'background-color' => '#000000',
'background-size' => 'cover'
) );
It seems to work because going into the WordPress Dashboard -> Appearances -> Background, I can add an image and have it shown in the Customizer space. But when I actually go to the page itself, it shows me a blank white background.
Is there an additional code I need to add to my '.php' files? There was a similar post previously here:https://wordpress.stackexchange.com/questions/259315/custom-background-image-not-showing-up
But I believe this does not work anymore, or maybe I'm doing my process wrong.
Based on the codex sample you need this format
$args = array(
'default-image' => 'https://cdn.pixabay.com/photo/2015/12/01/20/28/road-1072823__340.jpg',
'default-size' => 'cover',
);
add_theme_support( 'custom-background', $args );
Thank you for replying. I found out what the issue was with my code. It wasn't that my code was in an incorrect form, but I had forgotten to put a
<body <?php body_class();?>>
wherever I put my tag in.
Related
I created a custom post type in Wordpress and I would like to add support for thumbnails. I have created the post type specifying support for thumbnails, but in the editing window of the post type page does not appear the option to specify a thumnail.
I'm using Gutenberg as an editor, with the classic editor, there's no problem. Any solution?
Thanks!
First add theme_support within functions.php
add_theme_support( 'post-thumbnails', array( 'custom_post_type_name' )
Then add 'editor' and 'thumbnail' to supports and make sure you have show_in_rest set to true.
'supports' => array( 'editor', 'thumbnail'),
'show_in_rest' => true,
Otherwise it won't work in Gutenberg. Here is the documentation for supports:
https://codex.wordpress.org/Function_Reference/post_type_supports
You nee to enable support for Post Thumbnails.
https://codex.wordpress.org/Post_Thumbnails
The common way is to add
add_theme_support( 'post-thumbnails' );
in your functions.php
There's a bug report regarding this issue.
Kindly refer to the link Feature Image disappears only in Gutenberg with CPT.
As most of common solutions around the web doesn't work I will put only that sometimes themes or plugins use
add_theme_support( 'post-thumbnails', array( 'post', 'page', 'my_cpt_name' ) );
So it's worth to check this and add the cpt name to array.
Add this on your functions.php:
add_theme_support( 'post-thumbnails' );
I am using a simple theme in WordPress, that pulls it's customizers sections from the plugin ThemeHunk Customizer.
I want to hide certain sections in the customizer section, but when using $wp_customize, it isn't working.
This is what I am trying to hide:
$wp_customize->add_section('section_home_ordering', array(
'title' => __('Section Ordering', 'featuredlite'),
'priority' => 3,
));
This is located in the /wp-content/plugins/themehunk-customizer/featuredlite/customizer/customizer.php file.
I have added this to my functions.php file in my child theme directory:
function customize_register_init( $wp_customize ){
$wp_customize->remove_section('section_default_home');
$wp_customize->remove_section('pro_button');
$wp_customize->remove_section('Docs_button');
$wp_customize->remove_section('section_home_ordering'); - THIS IS THE SECTION I would like removed from the /plugin/ file
}
add_action( 'customize_register', 'customize_register_init', 99 );
It doesn't seem to remove though, like it would if you were removing a section from a parent theme.
Is there another method to do this, or is this not possible to remove from a plugin rather than a parent theme?
Thank you in advance.
SOLVED I use the customize_controls_enqueue_scripts hook to input custom CSS within the wordpress customizer, so I can display certain elements as hidden!
In theme your code works fine. Maybe it depends on action hooks order.
Have you tried?
add_action( 'plugins_loaded', 'customize_register_init', 99 );
You can simply go with these documentation as it shows you can disable particular section of Home Page (FrontPage). You can change order of appearance also from the Appearance > Frontpage Section > Section Ordering.
Reference Link: https://themehunk.com/docs/shopline-theme/#frontpage-section
https://themehunk.com/product/shopline-free-shopping-theme/
I am figuring how to redirect the url.
Via Inspect Element in Mozilla, I found out the link as below:
<a id="mw_title" href="http://yourdomain.com" title="My Site Title" target="_blank">My Workbook</a>
Is there a function that i can write in the child theme to overwrite the existing and redirect it to
http://yourdomain.com/example
and open in same page?
I am using wordpress with child theme and the plugin is adminimize and beginner on this.
Thanks guys and looking forward for your advise.
Redirect in php is done by
header("Location: yourside.php");
so if you can edit the code called on http://yourdomain.com you can add the line
header("Location: http://yourdomain.com/example.php");
or something like that.
Create a file called .htaccess in the doc root (web/httpdocs or www folder).
Copy the code below and save it in .htaccess file to redirect http://yourdomain.com to http://yourdomain.com/example
Redirect 302 / http://yourdomain.com/example
Note: Test it with 302 status, if everything was ok and redirection worked fine, then change it to 301.
Thanks guys !
You guys are awesome and supportive with prompt respond :)
I am using a wordpress plugin ( Adminimize ), I would like to hide all wordpress related items and restrict menus in admin dashboard toolbar.
12 hours ago I read and follow their advice and code one by one to hide all related wp and menu in admin dashboard. As i am a beginner, i realize that it was quite risky to do so.
Therefore I install that plugin, what i did a moment ago is:
I enable Dashboard and disable Admin Bar Back End Options, then i added a custom code into my php as below
// add custom menu in wp menu
add_action( 'admin_bar_menu', 'custom_wp_toolbar_link', 999 );
function custom_wp_toolbar_link( $wp_admin_bar ) {
if( current_user_can( 'edit_posts' ) ){
$args = array(
'id' => 'myworkbook',
'title' => '<span class="ab-icon"></span><span class="ab-label">'.__( 'Back To Homepage', 'some-textdomain' ).'</span>',
'href' => 'http://yourdomain.com/my-workbook/',
'meta' => array(
'target' => '_self',
'class' => 'myworkbook',
'title' => 'My Workbook'
)
);
$wp_admin_bar->add_node($args);
}
}
add_action( 'admin_enqueue_scripts', 'custom_wp_toolbar_css_admin' );
add_action( 'wp_enqueue_scripts', 'custom_wp_toolbar_css_admin' );
function custom_wp_toolbar_css_admin() {
if( current_user_can( 'edit_posts' ) ){
wp_register_style( 'add_custom_wp_toolbar_css', plugin_dir_url( __FILE__ ) . 'custom-wp-toolbar-link.css','','', 'screen' );
wp_enqueue_style( 'add_custom_wp_toolbar_css' );
}
}
This is how it looks
https://prnt.sc/fkzdr3
It works like a charm ! Please advise shall there anything to improve , passion to learn more.
TQ all !!
There are some basic options defined inside the basic file: ot-functions-admin.php
Since I have the OptionTree plugin implemented inside the theme files, I want to be able to update it every now and then.
That means, I will lose any custom options I have defined inside the file mentioned above.
For example, I have this inside the ot-functions-admin.php :
'menu_title' => apply_filters( 'ot_theme_options_menu_title', __( 'ACT', 'option-tree' ) ),
Which changes the title of the settings menu to "ACT" instead of "Theme Options".
I can change the text here of course, but in case of update, I will lose the changes and will have to redo them.
Is there any way I can write something like a filter inside functions.php that could help me achieve that?
add_filter( 'ot_theme_options_menu_title', 'ACT' );
I wrote the above, but unfortunately is not working.
Maybe the information below might be helpful to you:
'id' => 'ot_theme_options',
Thank you for your time.
I figured it out!
add_filter( 'ot_theme_options_menu_title', function ( $change_menu ){ return 'ACT'; } );
I've been having this problem for several weeks now, and would really like to get it resolved. I'm seeing issues like this all over the internet, however everyone is coming up empty.
I have 2 custom wordpress themes. One on a Linux (cPanel) Server, and one on a Windows (IIS) Server. Both of them have different custom themes, both of them are loaded with content. The two server php.ini's are identical (or as close as they can be). When I use the provided wordpress theme shortcodes are working fine. However when I take either of the custom themes, and make them active, shortcodes cease to work, they will show up on sidebars, and posts, but there is NO content, and by no content I mean: It shows the title of the widget, but not the actual widget itself.
I am quite literally at my wits-end here. This will be the 4th forum post in over a month on different sites, trying to get an answer. No one can help me anywhere. I'm hoping since I've had luck here with other issues, that maybe someone has seen this happen. Even custom shortcodes are not rendering.
I thought maybe it was because a script isn't called in the custom theme, but comparing the Wordpress TwentyTwelve theme and mine there are not any differences in the header file.
I've called wp_head(); and wp_meta();....So confused. Please help!!!
functions.php
<?php
function wpb_widgets_init() {
register_sidebar( array(
'name' => __( 'Main Sidebar', 'wpb' ),
'id' => 'sidebar-1',
'description' => __( 'The main sidebar appears on the right on each page except the front page template', 'wpb' ),
'before_widget' => '',
'after_widget' => '</div></div>',
'before_title' => '<div class="padding"><div class="top">',
'after_title' => '</div><div class="bottom">'));
}
add_action( 'widgets_init', 'wpb_widgets_init' );
apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file ))
?>
sidebar.php
<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
<?php dynamic_sidebar( 'sidebar-1' ); ?>
<?php endif; ?>
Without code this is difficult to answer, but a good shot might be the use of get_the_content() instead of the_content() within your loop. Using get_the_content() will not apply the the_content filters. See:
If you use plugins that filter content (add_filter('the_content')), then this will not apply >the filters, unless you call it this way (using apply_filters):
<?php apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file )) ?>
http://codex.wordpress.org/Function_Reference/get_the_content