Currently I'm making new theme and had the idea of adding featured image in the admin side of wordpress, unfortunately its not working this is what I have tried
I have added this code in functions.php
add_theme_support( 'post-thumbnails');
I also tried to change it
add_theme_support( 'post-thumbnails', array( 'post' ) ); // Add it for posts
add_theme_support( 'post-thumbnails', array( 'page' ) ); // Add it for pages
After I refresh and log in to my admin panel and tried to create new post or page featured image is not displaying.
I also tried deactivating my custom theme and activating Twenty Fifteen the featured images shows but if I activate my custom theme again the featured image is gone again.
I also have tried to look at SCREEN OPTIONS but I don't have any available checkbox related to featured image, please help me.
Can someone help or guide me what to do this because I'm new to this?
you can try to tie your add_theme_support call to WP action, for example after_setup_theme.
Here's sample code for this:
add_action('after_setup_theme', 'themename_post_thumbs_en', 11);
function themename_post_thumbs_en() {
add_theme_support('post-thumbnails', array('post', 'page'));
}
Related
The given page is a blog archive page that lists recent posts.
https://petcarepicks.com/
I want the featured image thumbnail on this page to load the same file size as it display (360px by 180px). I added the given code in functions.php of the theme, but it is still not working. It loads the old file of 408 x 204 size and display on new dimensions.
add_image_size('new-few-img', 360, 180,true);
the_post_thumbnail('new-few-img')
The new image size is registered, and the file appears in directory after regenerating the thumbnails. However, on front end it still loads the old dimensions and displays new dimensions (Forced by CSS).
I also tried using below line;
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'new-few-img' );
}
or
set_post_thumbnail_size(360,180,true);
or
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 360, 180, true );
}
Please help me resolve the issue.
Add below code into you function.php file.
function register_new_thumbnail() {
add_theme_support( 'post-thumbnails' );
add_image_size('new-few-img', 360, 180,true);
}
add_action( 'after_setup_theme', 'register_new_thumbnail' );
Now your new thumbnail size is registered and will work on only new images. To crop your already used image you need a plugin which will help you to regenerate this thumbnail size.
https://wordpress.org/plugins/regenerate-thumbnails/
https://wordpress.org/plugins/regenerate-thumbnails-advanced/
I hope this may help your issue.
I have a website where product gallery is not working on product detail page, I have tried to add third party plugin but nothing seems to working.
Here when you click on product image, it should open in lightbox as product gallery.
https://bosheimsmarken.no/produkt/reinrot-te-med-tea-shotnon-binding-subscriptions/
Try to install this plugin and check if there is option to disable this gallery in theme options or woocommerce options.
Product Gallery Slider for Woocommerce by codeixer
Also add this code in your functions.php in active theme
add_action( 'after_setup_theme', 'bbloomer_remove_zoom_lightbox_theme_support', 99 );
function bbloomer_remove_zoom_lightbox_theme_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
remove_theme_support( 'wc-product-gallery-lightbox' );
remove_theme_support( 'wc-product-gallery-slider' );
}
I am making a wordpress theme
But the problem is i can not enable feature image option in Portfolio
I have added the following code in the function.php
add_theme_support( "post-thumbnails", array('portfolio', 'post'));
This code is working for posts but not for portfolio
is it because of any of these plugins that i am using
Advanced Custom Fields
Custom Post Type UI
Akismet
enter image description here
try this in fucntion.php file
function custom_theme_setup() {
add_theme_support( 'post-thumbnails', array('post', 'page', 'popup') );
}
add_action( 'after_setup_theme', 'custom_theme_setup');
my search result doesn't show excerpt content of pages on WordPress it only show for the post
advise please
Taken from http://codex.wordpress.org/Function_Reference/add_post_type_support
<?php
add_action('init', 'my_custom_init');
function my_custom_init() {
add_post_type_support( 'page', 'excerpt' );
}
?>
Adds excerpt support for the 'Page' post type. Paste this code into your themes functions.php file (ref http://codex.wordpress.org/Functions_File_Explained)
I am trying to just display the wordpress categories in a metabox on a different page, the page is custom.
Like a blank page and I am trying to add the wordpress metabox on that page, and be able to add new categories.
Screencast example of what I want to achieve.
It's very simple, just call the following function
add_action( 'init', 'add_cat_meta' );
function add_cat_meta()
{
register_taxonomy_for_object_type( 'category', 'custom_page' );
}
Notice the custom_page, replace custom_page with your original custom post name, for example if you have following to register a custom post
register_post_type( 'restaurant',
array(...);
);
Now to add the category meta box for that custom post you can use
register_taxonomy_for_object_type( 'category', 'restaurant' );
Also, if you want to add the category meta box in the page section then you can use
register_taxonomy_for_object_type('category','page');
But pages are different than posts and don't require a category.