Adding the Classic Editor to a Gutenberg Block Template - wordpress

NOTE: Here is a video that helps explain my question: https://drive.google.com/file/d/1c3pS-j8yq75GAwGDrrMMh9X7fDrCKV5R/view?pli=1
I am creating a custom post type that includes a set of blocks as a template. My basic code looks like this:
function register_article_post_type(){
$post_settings = array(
'label' => 'Articles',
'public' => true,
'show_in_rest' => true,
'template_lock' => 'all',
'template' => array(
array( 'core/heading',
array(
'placeholder' => 'Add Categories Heading...',
'className' => 'tour_categories_heading'
)
),
)
);
register_post_type('article', $post_settings);
}
That will create a Custom Post Type called Articles which has a singular Heading block. The thing is, I don't want a heading block, I want the Classic Editor block.
But I can't figure out how to add it. I can easily change the Heading block to a different block (say the paragraph block) if I change array( 'core/heading', to array( 'core/paragraph',.
But when I check the code in Gutenberg for the name of the Classic editor, nothing shows up. As such, I cannot figure out how to add a Classic editor to the custom post type.
Any ideas.

Try core/freeform - should be the slug for the classic editor block

Related

How Do you Properly Add An Image Control To Wordpress Customizer?

Wordpress admin customizer control is incomplete. How can I fix it?
My Code:
$wp_customize->add_setting('swag_header_media');
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'swag_header_media', array(
'label' => 'Current Image Selection',
'section' => 'swag_header_media_section',
'active_callback' => 'header_show_image_selection_settings_callback',
'settings' => 'swag_header_media'
)));
The results are incomplete. I can select an image from the and the image show up in the frontend of the theme. However, the image selected does not show that it is being used in the control.
In other words(see screenshot), you can see the background image being used(phone), but it doesn't show that it being used in the admin customizer control. Its says "Current Image Selection", but it's empty with no buttons below it to change or remove it.
When you inspect the page, is there any errors?
It is a bit hard to figure out with so little data.
Try this 'settings' => 'themename_theme_options[swag_header_media]',
Try:
$wp_customize->add_setting('themename_theme_mods[swag_header_media]',array(
//'default' => 'image.jpg',
//'capability' => 'edit_theme_options',
//'type' => 'option'
));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'swag_header_media', array(
'label' => 'Current Image Selection',
'section' => 'swag_header_media_section',
'active_callback' => 'header_show_image_selection_settings_callback',
'settings' => 'themename_theme_mods[swag_header_media]'
)));
if that doesnt work,I suggest to change swag_header_media to other keyname. I suspect that key name might be used by other control/funtion too. So, try to add any 1 letter to that keyname, and see the result. Also, if you have any caching on site, turn it off.
also, the problem could be with callback,

WordPress - How do I retrieve custom post type posts from output of wp_get_archives

I am new to WordPress and learning by implementing. Today I have created a list of archives using wp_get_archives for a custom post type. The list comes up fine!
$args = array(
'type' => 'monthly',
'limit' => '15',
'format' => 'html',
'before' = '',
'after' => '',
'show_post_count' = true,
'echo' => true,
'order' => 'DESC',
'post_type' => 'travelog'
);
wp_get_archives($args);
Now I am stuck with two things and no idea how to solve them!
[ A ]
What I want to accomplish:
I want to achieve the functionality that when somebody clicks on an item from the list it would take him to another page with posts listed for that period only.
What is happening:
WordPress takes me back to site's home page.
How can I tell WordPress to go to a page and display the posts for that period. Posts can be custom post types as well.
[ B ]
What I want
With a Custom Post Type passed ('post_type' => 'travelog') link for each item be like http://local.tourplanner.com/2017/03/travelog
What I am getting
It is like http://local.tourplanner.com/2017/03/?post_type=ravelog
With 'post_type' => 'post', however, there is no query string added to and they look like http://local.tourplanner.com/2017/03
If possible I would love to achieve this without using any plugin.
Looking forward to your suggestions.

A2LiX Translation Form labels options

I'm using KnpLabs/DoctrineBehaviors/Translatable and A2LiX Translation Form to translate my entities in a Symfony application. It works very well. However, when the form is rendered there is a "translations" title that I would like to delete and a "EN [Default]" text on a tab that I would like to change.
In the examples of the doc, there's a "medias" example so I imagine that we can change this text. Moreover, the tabs don't have this [Default] text. So I imagine that's possible to change them.
And this is mine:
Does anybody know how to do it? If we take a look on the form type options we don't see anything concerning the "Translations" label. For the "Default", I can't see where I should search for it.
Default template file is located at vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Resources/views/default.html.twig. If you want you can specify your own template and set it in config.yml file, like this:
a2lix_translation_form:
....
templating: "#SLCore/includes/translation.html.twig"
More information can be found here.
For the "translations" title, I was able to override it adding a label to the form type just like a normal field. However, it is not possible to use a blank value. I had to use ' ' in order to override the text.
->add('translations', 'a2lix_translations', array(
'label' => ' ', --> this overrides the translations title
'fields' => array(
'name' => array(
'field_type' => 'text',
'label' => 'blabla'
),
'description' => array(
'field_type' => 'textarea',
'label' => 'bleble',
)
)
))
For the "Default" label, I still have no solution.

Wysiwyg mo editor for Drupal 5 forms (Form API): How to enable it for several textareas?

I am trying to create a form with the Drupal 5 form API that has two textareas, both of which should have have a wysiwyg editor enabled to allow HTML formatted input. However, only the second textarea has the editor enabled, the other one displays the "Input format selector", but not the editor controls. I have tried this with TinyMCE 3.3.9.3 and 3.3.9.4b and CKEditor 3.5.1.6398 both using the wysiwyg module integration, the result in both cases is the same.
In this related question it is mentioned that there might be a problem of identical IDs. I have no clue how to transfer this solution to the Drupal Form API, since I gave the two fields different names. In the generated HTML, they have separate HTML ids based on the Drupal names I assigned.
The code I used to create the text areas is the following:
$form['oos'] = array(
'#tree' => false,
);
$form['oos']['oosmessage'] = array(
'#description' => t('Something'),
'#title' => t('Generic out of stock message'),
'#type' => 'textarea',
);
$form['oos']['format'] = filter_form(1, 20, array('format'));
$form['oosmd'] = array(
'#tree' => false,
);
$form['oosmd']['oosmessage_date'] = array(
'#type' => 'textarea',
'#title' => t('Out of stock message until a specific date'),
'#description' =>t('Something else.'),
);
$form['oosmd']['format'] = filter_form(1, 20, array('format'));
Thanks!
Ellen
Try to give the two textareas different ids and see if that works.

WordPress Custom Taxonomies

I have the following code to build a custom taxonomy for my portfolio:
add_action( 'init', 'create_pc_db_taxonomies', 0 );
function create_pc_db_taxonomies() {
register_taxonomy( 'type', 'post', array( 'hierarchical' => true, 'label' => 'Type', 'query_var' => true, 'rewrite' => array( 'slug' => 'type' ) ) );
}
I have created a portfolio category on my site (I removed the /category/ base) and have created some items and set the custom taxonomies against them. So I get the following setup:
http://domain.com/portfolio/item1/ but what I want is for the taxonomy links to look like this: http://domain.com/portfolio/type/web and then this will show a list of portfolio items related to the that type. At the moment they are root like http://domain.com/type/web these create 404's, but I have also tried adding 'portfolio/type' as the taxonomy slug but it just creates a 404 as well, but i'm pretty sure this is the wrong way of doing it anyways. Any help?
Thanks
EDIT: The site is here: http://driz.co.uk/ all the work is in a category called Portfolio and under each pic is the title and custom taxonomy (if you click on them you will get the 404)
Make sure all plugins are disabled (at least ones that tweak with rewrites), and delete the option rewrite_rules in your wp_options table.
Now remove any hooks in your theme that meddle with custom taxes and post types, and run this on init;
register_taxonomy(
'type',
'post',
array(
'hierarchical' => true,
'label' => 'Type',
'rewrite' => array('slug' => 'portfolio/type')
)
);
In your permalink settings, choose one of the default options, and make sure both a category and tag base is set, then update.
Dump $wp_rewrite as you did before, and you should see a few lines like so;
[portfolio/type/([^/]+)/page/?([0-9]{1,})/?$] => index.php?type=$matches[1]&paged=$matches[2]
[portfolio/type/([^/]+)/?$] => index.php?type=$matches[1]
These should be near the very beginning of the array, before tags, categories and the like.
Let me know how you get on!
(When I run the code in my install of WP 3.0-beta-2 it works, so I assume something funky is happening at the moment).
I'm sure you can fake a slug like that, using portfolio/type - the key is, once you've updated your code, you'll need to flush the rewrite rules.
Do this by simply re-saving your permalink settings in the admin.

Resources