I use Wordpress with Timber (as template renderer), and Advanced Custom Fields. I'm struggling with some sub page options.
My problem is that I can't get the options on the right posts (my jobs) – it's only available on the job overview page.
I've created an options sub page to my custom post_type "job", like so:
if (function_exists("acf_add_options_page")) {
acf_add_options_sub_page(array(
"page_title" => "Job options",
"menu_title" => "Job options",
"menu_slug" => "job_options",
"capability" => "edit_posts",
"parent_slug" => "edit.php?post_type=job"
));
}
And I'm able to get that options on the job-overview page, like so:
$context["options"] = get_fields("options");
But when I run that same command on the posts with post_type "job", then it returns null.
How can I get that options to affect the posts with post_type "job" and not the overview?
** EDIT **
Okay, so I found out that somehow it had worked, since I could get SOME of the options, and I could edit them in ACF, but I couldn't add new options. Somehow the link to "options" is broken. I have no idea how to fix this.
This was a bug in version 5.3.2.
This has been fixed in version 5.3.2.1.
Related
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.
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.
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 can i filter the link given in "link to existing content".
As in the above image. I just want WSP BANNER TO BE SHOWN.
where WSP BANNER & CALENDAR are custom post_type
Any help will be appreciable.
Currently there are no ready filters available for this purpose. A ticket has been posted for the request.Lets hope we get one soon.
Till then you can create your own filter.
Open includes/class-wp-editor.php and make folowing changes at line no 712
$pt_names = apply_filters('custom_insert_link_suggestion_filter',array_keys( $pts ));
we just added a new filter instead of getting all the public post types
Then in your theme add following code to filter the internal link custom post type
function my_filter_function($allowed_post_types)
{
if( condition chek)
{
return array('page','your custom post types');
}
}
add_filter('custom_insert_link_suggestion_filter','my_filter_function',10,1);
There is a plugin that could be helpful for you: B09 Link to Existing Content
It has a filter called "link_to_existing_content_post_types", that enables you to control which post types should be searched.
You can also use it together with this plugin, if you also want to have complete control over the search results: Search Everything.
Consider an example where my site is configured on wp.abc.com and I point my root domain www.abc.com to the new site. I need to update the URL's in General Setting. So when I update the URL, it is reflected in menu items etc. Will it be reflected in the content area links aslo?
On my WordPress site, I'm using a plugin called "Vera Meta Boxes" that lets me add custom meta boxes to pages (not referring to custom post types).
So now every page has meta box that says, "Show on Home page" with a checkbox, that when selected has the value of "yes".
Now on my homepage, I want to show the titles and featured image of any page that has "Show on Homepage" checked.
The vera meta box plugin says to use:
<?php get_post_custom_values('your_custom_field_key_here'); ?>
So I would use:
<?php get_post_custom_values('show_on_homepage'); ?>
But how do I do the rest? Conceptually, it would be something like:
LOOP Query Pages > if <?php get_post_custom_values('show_on_homepage'); ?> = yes show title and featured image and repeat loop until all pages with "show_on_homepage" are shown.
Well, I haven't tested this, but according to the docs you should be able to use this query:
array('post_type'=>'page', 'meta_query' => array( array('key' => 'show_on_homepage') ) )
Note that meta_query is an array of arrays
This is 3.1 code, the 3.0 version should look like this:
array('post_type'=>'page', 'meta_key' => 'show_on_homepage')