Wordpress CMB2 show-on page template - default page template - php

I am using CMB2 and would like to only show a particular CMb2 metabox on the default page template. I have tried passing a value of page.php as the value of the show-on filter but its not working. Any ideas welcome? I could write my own custom show-on filter but I am sure the functionality must already exist.

It's been a while, so maybe you've found the answer. But since I've been looking myself as well, let me post the result here for future reference.
The solution is simply, instead of 'page.php', just use 'default' as the value for the show-on filter:
'show_on' => array( 'key' => 'page-template', 'value' => 'default' )

#ruude3 answer works. Also you'll need to either save the new page as a draft or publish it before the meta fields will appear.

Related

Custom taxonomy images - output to single product pages

I'm trying to display images attached to custom taxonomies on the individual product pages. I've used the Custom Taxonomy plugin (https://wordpress.org/plugins/taxonomy-images/) and added the images using Advanced Custom Fields. I have 2 custom taxonomies called 'range_logo' and 'features', each with images assigned to them. I need to output the images to the single product page using the hook 'woocommerce_before_add_to_cart_form'.
As you can see below, I have tried outputting a line of text to test if the hook is working correctly, and it is, but the taxonomy image isn't shown when I add the code which is supplied with the Taxonomy Images plugin.
add_action(
"woocommerce_before_add_to_cart_form","product_taxonomy_image");
function product_taxonomy_image () {
echo 'Taxonomy image here';
print apply_filters( 'taxonomy-images-queried-term-image', '' );
}
Expected results are that the appropriate taxonomy image for the product would be displayed. Instead I got this error:
Notice: term_taxonomy_id is not a property of the current queried object. This usually happens when the taxonomy-images-queried-term-image-id filter is used in an unsupported template file. This filter has been designed to work in taxonomy archives which are traditionally served by one of the following template files: category.php, tag.php or taxonomy.php. Learn more about template hierarchy. in /var/sites/a/mysite.com/public_html/wpnew/wp-content/plugins/taxonomy-images/legacy/includes/public-filters.php on line 398
I'm using the Avada theme - maybe the layout of the theme's template files could be the reason for the error? I think I may need to use archive.php instead, but I don't have much experience with PHP.
I've tried a few possible solutions and have looked elsewhere for help, but I've hit a wall with getting this to work and I'm not sure what I should be trying next.
welcome to the community. First off, I would like to mention that you have written a bit confusing detail about the taxonomy images as you have mentioned using the plugin Taxonomy Images as well as Advanced custom fields
If you are using the former plugin, you can do something as shown below:
add_action("woocommerce_before_add_to_cart_form","product_taxonomy_image");
function product_taxonomy_image () {
print apply_filters( 'taxonomy-images-list-the-terms', '', array(
'before' => '<div class="my-custom-class-name">',
'after' => '</div>',
'before_image' => '<span>',
'after_image' => '</span>',
'image_size' => 'detail',
'taxonomy' => 'product_cat',
) );
}
The above code will give you the images from the category associated with that product. If it is another custom taxonomy that you created, please change the value in taxonomy parameter.
If you are using ACF you will have to get product terms first. Let me know if that's the case and I will share that code with you.

Bypass OptionTree filters via functions.php

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'; } );

How can I change my page name in Wordpress? Do I need to edit my URL .htaccess?

My first post so I hope someone can help :)
I need to change http://designoriginal-test.co.uk/ef-travel/portfolio to http://designoriginal-test.co.uk/ef-travel/exhibitions
How can I go about doing this? There is no 'physical' page in the Wordpress backend so I am not able to change the slug manually.
Thanks in advance!
Zak
Looking at your site's source code I see body has classes post-type-archive and post-type-archive-portfolio, so it's not a taxonomy archive but a post type archive.
<body class="archive post-type-archive post-type-archive-portfolio nictitate-builder nictitate-header-style-1">
So, portfolio is a Custom Post Type. This allows two possibilities:
You're using a plugin to handle CPT's (eg: Custom Post Types UI).
In this case, you should have a submenu in your WP Dashboard where you could rename the post type.
Your CPT's are defined in your custom theme's (or custom plugin) source code
In this case, you should locate there (check your functions.php) some piece of code like this:
register_post_type( 'portfolio', … );
where you'll be able to rename the portfolio too.
In both cases I recommend you to backup your Database first. And if you're editing some source code files, backup them too before making changes.
Update:
After some research on the theme I've seen there's a free version of it. This version requires (via TGM Plugin Activation) a custom plugin from the same developer named Kopa Nictitate Toolkit.
function kopa_register_required_plugins() {
$plugins = array(
array(
'name' => 'Kopa Nictitate Toolkit',
'slug' => 'kopa-nictitate-toolkit',
'source' => 'http://downloads.wordpress.org/plugin/kopa-nictitate-toolkit.zip',
In this plugin they register the portfolio's CPT. So, check if you have this kopa-nictitate-toolkit folder in your /wp-content/plugins/. If so, there's a file named portfolio.php where they register the Portfolio CPT.
Edit:
You'll see that besides registering the CPT
register_post_type('portfolio', $args);
they also register some custom taxonomies.
register_taxonomy('portfolio_project', 'portfolio', $taxonomy_category_args);
register_taxonomy('portfolio_tag', 'portfolio', $taxonomy_tag_args);
You'll need to change this too so the theme won't broke. Check register_taxonomy docs.
Hope this helps!
Just go to the page and change the page name and its Permalink

TYPO3 TCA, hide tab in translated item

In my Extension I create several tabs for the backend with --div--, the code looks something like this:
'types' => array(
'0' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1,--div--;My Tab, title, category,
),
While there is an easy way to hide a single field in the translated item with: 'displayCond' => 'FIELD:sys_language_uid:=:0',, I have no idea how to hide a whole tab.
Does anybody know how I have to write the 'types' array to hide "My Tab" in the translation records? Thank you in advance.
Edit (Solution):
Using config as stated in the answer is possible, but there is another way I discovered by accident: If you hide all fields that are associated with a tab with 'displayCond' => 'FIELD:sys_language_uid:=:0', the tabs will also be hidden.
I think you may need to use tsconfig.
Please check the section: "New content element wizard (mod.wizards.newContentElement)" in this link: http://typo3.org/documentation/document-library/core-documentation/doc_core_tsconfig/4.3.2/view/1/5/

How to create custom forms for custom content type in wordpress?

Is there any way to create forms for a particular content type and submit it form the site itself. I have 2 content types created in my Wordpress and I want to create a form to post to a particular content type. Also is it possible to create the form as a page in wordpress?
regards - dj
I have used the following method to achieve this:
I have used the shortcode function to create forms in the site. Here you can see the documentation for adding shortcodes. Submit page was also a 'page' with shortcode. So I have collected the values in the shortcode function and added the content to the wp_posts table using wp_insert_post function. You can see the documentation about wp_insert_post() here. I hope this help :)
regards dj
You have to add a function to your functions.php file. Something like this example:
add_action(‘init’, ‘mycustomcontent_init’); //enable custom content types
function mycustomcontent_init() {
// create content type Crafts
$args = array(
‘label’ => __(‘Crafts’), //content type name to be displayed in the wordpress dashboard
‘singular_label’ => __(‘Crafts’), //content type name to be displayed in the wordpress dashboard
‘public’ => true,
‘show_ui’ => true, // show the user interface for this content type? true=yes false=no
‘_builtin’ => false, //declartion to the system that it’s a custom content type and not a built in content type
‘_edit_link’ => ‘post.php?post=%d’,
‘capability_type’ => ‘post’, //set the content type features, here we setting it to the features of a standard post
‘hierarchical’ => false,
‘rewrite’ => array(“slug” => “crafts”), //prefix to the url alias for this content type, eg: mysite.org/crafts/model-ships
‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’)
);
register_post_type( ‘crafts’ , $args );
}
taken from here.
Also, read up on the Wordpress Documentation for Custom Post Types

Categories