Reposition elements in Wordpress post editor - wordpress

I'm developing a wordpress website and I've added some custom fields. They work just fine, but I wanted to reposition them in the admin editor.
So for example you have the WYSIWYG editor with some little widgets on the side, like categories, publish widget and so on. Some of my custom fields are just checkboxes, so I was wondering if it was possible to put those in the admin sidebar, rather than sticking them underneath the WYSIWYG editor.
How can that be achieved?

Check the documentation for add_meta_box.
add_meta_box(
$id,
$title,
$callback,
$post_type,
$context,
$priority,
$callback_args
);
$context - The part of the page where the edit screen section should be shown ('normal', 'advanced', or 'side').

Related

Add fields to wordpress footer

I have a wordpress widget on my footer with contact details and the widget has editable fields:
Title
Email
Phone
Fax
Address
How can I edit this widget to include additional fields? I am new to wordpress and I am unsure if this is possible. In the help documentation for the widget it says the following:
How do I add additional fields to the contact widget?
Adding additional fields to the contact widget is as simple as adding a WordPress filter.
Here is an example:
add_filter( 'wpcw_widget_contact_custom_fields', function( $fields, $instance ) {
$fields['cellphone'] = [
'order' => 2,
'label' => __( 'Cellphone:', 'YOURTEXTDOMAIN' ),
'type' => 'text',
'description' => __( 'A cellphone number that website vistors can call if they have questions.', 'YOURTEXTDOMAIN' ),
];
return $fields;
}, 10, 2 );
However I am unsure as to where I would have to add this information
Widgets were originally designed to provide a simple and easy-to-use way of giving design and structure control of the WordPress Theme to the user, which is now available on properly "digitized" WordPress Themes to include the header, footer, and elsewhere in the WordPress design and structure. Widgets require no code experience or expertise. They can be added, removed, and rearranged on the Theme Customizer or Appearance > Widgets in the WordPress Administration Screens.
more details
2> visit blog i follow
if the widget don't have optionnal fields options altering it with new code can be the wrong approach. If the widget is updated you will loose your update.
The right way is to create a new widget with all the functions you need, maybe you can fork the existing widget and implementing your field.
Or you can just edit the footer.phpand including the widget logic in it.
Docs :
Widget api
Template development in wordpress

Moving WordPress default menus in admin

I've been digging around the codex trying to find a way to move the default menus around in the admin area. specifically i want to take the customizer from the appearance menu and move it to my custom menu. same with other menus. Is there a list somewhere of for them or a file to edit with the orders or way to move them. I don't want to edit any core files though as obviously will break on any update.
I already have my own menu: image of own menu code is below for mine.
function dcmaintheme_menu() {
add_menu_page( 'dcmaintheme_adminpage', 'Dragon Cove Theme', 'manage_options', 'dcmaintheme_adminpage', 'dcmaintheme_page', content_url( 'themes/dragon-cove-base/img/icon.png' ), 10 );
add_submenu_page( 'dcmaintheme_adminpage', 'Admin Options', 'Admin Options', 'manage_options', 'submenu_adminoptions_page', 'submenu_adminoptions_page' );
what id like to get is another sub-menu that links to say the appearance->customiser and have it in my custom menu.
You can use this plugin, it will allow you to customize the Admin Toolbar and the Admin Side menu. You can choose what content on the menu to display to a specific user role.

Wordpress - Different sidebar for each page

Client needs an website to migrate into WordPress.
In this website each page has an sidebar with different content inside it
In some page accordion comes under sidebar, in some just text and images are visible
How to implement this in WordPress?
If template has to be created, there are many page it cant be done so
Even for every page different sidebar widget is not also possible
Guide me a way to implement this
A different sidebar (widget) are can be added to each page in two steps:
Add the sidebar to the theme template using the page slug as part of the sidebar name. This ensures that the sidebar has a unique name for that page.
Register the sidebars for each page in functions.php for your theme
Add the sidebar to the theme template
In your theme template, add the following code where you want the widget area to be:
<?php
global $post;
dynamic_sidebar( 'widget_area_for_page_'.$post->post_name );
?>
Register the sidebars
In functions.php for your theme add the following block of code to register the sidebars for each page in your site. Note that it includes draft pages etc so that you can edit the widgets while still in draft mode.
function myTheme_registerWidgetAreas() {
// Grab all pages except trashed
$pages = new WP_Query(Array(
'post_type' => 'page',
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit'),
'posts_per_page'=>-1
));
// Step through each page
while ( $pages->have_posts() ) {
$pages->the_post();
// Ignore pages with no slug
if ($pages->post->post_name == '') continue;
// Register the sidebar for the page. Note that the id has
// to match the name given in the theme template
register_sidebar( array(
'name' => $pages->post->post_name,
'id' => 'widget_area_for_page_'.$pages->post->post_name,
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
}
}
add_action( 'widgets_init', 'myTheme_registerWidgetAreas' );
Hope it helps!
There's a great plugin for this:
https://wordpress.org/plugins/custom-sidebars/
Sometimes it is necessary to show different elements on the sidebars
for some posts or pages. The themes nowadays give you some areas to
put the widgets, but those areas are common for all the posts that are
using the same template. NOTE: You need to use a theme that accepts
widgets to make this plugin work.
I think this is what you're looking for.
This can be done with the https://wordpress.org/plugins/jetpack/ plugin. Once activated you can choose what widgets display on what pages:
The Widget Visibility module enables you to configure widgets to appear only on certain pages (or be hidden on certain pages) by using the Visibility panel.
Visibility is controlled by five aspects: page type, category, tag, date, and author. For example, if you wanted the Archives widget to only appear on category archives and error pages, choose “Show” from the first dropdown and then add two rules: “Page is 404 Error Page” and “Category is All Category Pages.”
Just tried custom-sidebars with the latest version of wp. Had a hard time deleting it. Database is still messy. Plugin did not work. Maybe the 'pro' version is useful, but the 'non-pro' version would not add a sidebar to the page. It was clunky and did not allow per-page sidebars. It says its not been tested with the latest wp, maybe that's the problem.
You can create custom sidebar for for each post and pages with the help of plugin. There are a few plugins which enables you to create your custom sidebar. Here in this tutorial we are using Easy Custom Sidebars. Download and install this plugin in your website and activate it.
After successfully activating the plugin go to Appearance > Sidebar Replacement
From this page give a name to your custom sidebar and click on the Create Sidebar button. After that go to the Sidebar Properties option. Here you need to select the properties where you want to replace your created custom sidebar instead of theme sidebar. You can view your available option in the drop-down menu. Select it and provide a description on the Sidebar Description field.
Now in the last step select the post or pages to add this custom sidebar. You can see all the option in the left column. You can select specific post, page, category , tag, author to add this sidebar. Just select it and click Add to sidebar option.
For better understanding you can follow this tutorial

Wordpress post thumbnails (featured image) metabox not appearing in custom post

I've enabled featured images with the following code:
if(function_exists('add_theme_support')){
add_theme_support('post-thumbnails');
set_post_thumbnail_size(145, 9999999999999999999999999999999999999999999, false);
}
and everything works fine except that I can't find the featured image metabox in my custom post editor. Under the "show" menu I only have the number of column and other 2 unrelated options. I'm on the last version of wordpress (3.1, I think?).
Can you help me? I've already tried everything I found on this website and elsewhere.
Thanks in advance.
The correct way to do this is inserting all this code in functions.php
add_theme_support('post-thumbnails', array('events'));
(where events is the name of my custom post, you should use yours)
function create_event() {
register_post_type( 'events',
array(
//...
'supports' => array('thumbnail', 'title', 'editor')
//...
)
);
(thumbnail does the trick, but don't forget title and editor if you want to be able to have a title in your post or edit it!)
And last be sure to tick the box called 'thumbnail' - I suppose, my installation is in another language - under screen options (screen options is a button in the upper right corner, Google the name if you can't find it).

In Wordpress CMS, the controls under the WYSIWYG editor

I want to create a wordpress plugin where it adds additional controls underneath the WYSIWYG editor when adding pages/posts. But I don't know what keywords I'm supposed to google for to find relevant tutorials on how to do it.
Can someone provide me with resources?
It's called add_meta_box() - call it within a hooked admin_init function like so;
function my_custom_meta_box()
{
add_meta_box(
'my_meta_box_id',
'My Meta Box Title',
'my_meta_box_callback',
'post', // either post, page or link,
'normal', // position of the meta box,
'high' // position priority
);
}
add_action('admin_init', 'my_custom_meta_box');
function my_meta_box_callback()
{
echo 'This is the content of my meta box!';
}
Do you want the filter reference for hooks to add to the editor? Plugin API/Filter Reference « WordPress Codex There are lots of plugins that add controls to the editor: WordPress › WordPress Plugins - TinyMCE
I've written a good tutorial on adding WordPress Meta Boxes additionally check out my WPalchemy Meta Box PHP Class which will help you create meta boxes with ease.

Resources