I’m using Archives widget dropdown from Admin panel on my blog listing page and I need to change the select label from "Select Month" to "Archives".
The original widget_archives_dropdown_args filter is inside wp-includes/widgets/class-wp-widget-archives.php file.
I have created the following function to update this label, but can make it work:
function ArchiveSelectTitle($archive_args){
$archive_args['type'&'monthly'] = __('Archives');
$archive_args['limit'] = 12;
return $archive_args;
}
add_filter('widget_archives_dropdown_args', 'ArchiveSelectTitle');
Any ideas how it should look like? Your help is very appreciated!
Unfortunately the widget_archives_dropdown_args filter only allows you to filter the type, format and show_post_count values. There is no filter available for the select label.
I would recommend that you set the widget title to 'Archives', and keep the label as is. The label on the select element is descriptive of the function of the dropdown, its purpose is to give the user an indication of what to do, so using the word 'Archives' there wouldn't really make sense.
Related
Right now my featured image for a page template is pulled from the standard Featured Image option on the right side of the new page.
I have my CSS in my stylesheet that says object-fit: cover since it's an absolute image instead of a background image
Each image is positioned a little differently and what i'd like to do is make it so that i can set a specific object-position: x x for each image.
So, for one image, if it's cutting off someones head, i could change it to object-position: center bottom; for example or vice versa.
Does anyone know the best way of doing this ? Any way for some plugin that would allow me to dictate lets say 3 options based off a drop down from the backend of WP like:
Background:
Option 1: center top
Option 2: center
Option 3: center bottom
And then in the CSS i could set a class that would correspond to those? This way each featured image doesn't need to be one way.
Thanks!
You should implement a custom meta field (a plugin like ACF or CMB2 is the easiest solution) and then use its value on the frontend.
<?php
if (has_post_thumbnail()) {
$post_id = get_the_ID();
$custom_class = get_post_meta($post_id, 'my_custom_image_class', true);
// ACF example
// $custom_class = get_field('my_custom_image_class', $post_id);
the_post_thumbnail('post-thumbnail', ['class' => $custom_class]);
}
Rather than adding another plugin (though Pods or ACF would be the easiest route), you could do this relatively simply by leveraging WP built-in features.
1. First enable custom fields in your post edit screen
Hit the three dots in the top-right; then go to Preferences, then enable Custom fields.
2. Add a custom field at the bottom of the post edit screen.
Give your custom field a name (say, "photo-style") and then its value is a single class name that you can switch out depending on needs, e.g. "photo-center", "photo-top", etc.
3. In Admin -> Tools -> Theme File Editor add the following to your Theme Functions file
add_filter( 'body_class', function( $classes ) {
$my_post = get_the_ID();
$new_class = get_post_meta($my_post, 'photo-style', true);
if($new_class !== "false") {
return array_merge( $classes, array( $new_class ) );
}
return $classes;
} );
4. Now, when you load your post, you can open page inspector and see the page body has your new class name ("photo-center, etc.") added.
Then you can make whatever CSS changes you need to in customizer and you're set.
The only drag is that you'll need to remember to add the custom field every time. Maybe not a major issue if it's a site you'll be managing yourself, but were it for a customer I'd think about a more easy-to-manage solution.
UPDATE. If you're using ACF
Ignore steps 1 and 2 above. Go to Custom Fields in admin. Add a new field group, setting it to display on posts/pages etc as you need.
Make it a select, with the options you want (center, center-top, etc.) and set its name to "photo-style". Edit one of your posts and select the right photo styling from the new dropdown.
Steps 3 and 4 are the same as above. Add the new function then style with css. If you check dev tools you'll see that body now has the class you selected from your drop-down list on it. You could then do something like:
body.center-top .wp-featured-image {
object-fit:top;
}
body.center .wp-featured-image {
object-fit:center;
}
I'm using Genesis framework and I have this page (http://staging.seedcreativeacademy.co.uk/short-courses/) showing the categories of my custom post type short_courses. I have changed the category name to course_type, by creating a new custom taxonomy.
This is how I want it to work so far (styling needs sorting out admittedly!) Im also using CPT UI plugin.
Now, when I click through to a category, is displays each 'Course in a nice masonry block as you will see here: http://staging.seedcreativeacademy.co.uk/course_type/digital-marketing/
However, I dont want this pages to look like this and I've tried adding custom template for the following:
Archive-short_courses.php & taxonomy-short_courses.php
Archive-course_type.php & taxonomy-course_type.php
But it doesnt seem to alter the layout at all...
Once I pass this hurdle I will want to alter the single.php page for these short courses, but I thought I would start with this first.
Im not sure if genesis blocks this and sets a site wide default? I know if sets a site wide default for the archive settings but I cant find anything about a template, plus i dont know if I shoujld be searching for tutorials on archive.php pages, category.php pager or taxonomy.php pages...
Can someone help me clarify things please?
course_type is a term name, not taxonomy name.
So, these are correct for your case:
category-course_type.php (category-{slug}.php is correct format. So check if course_type is correct slug of that category)
single-short_courses.php
Just in case, try reload permalinks via Settings->permalinks->save after making these changes.
Looks like your theme or some plugin is adding masnory class to body tag, which then is styled by your child theme. You need to filter that class out of your body tag and then might styling goes to non-masonary styling.
Add following code to your taxonomy-course_type.php file, and also make sure you have genesis(); call as the last thing in the template.
add_filter('body_class', 'remove_body_class', 20, 2);
function remove_body_class($wp_classes)
{
foreach($wp_classes as $key => $value)
{
if ($value == 'masonry') unset($wp_classes[$key]);
}
return $wp_classes;
}
Above could should be in custom taxonomy template, which also have genesis(); as last line.
I would like to create a metabox in the section of edit post menu. Like Tags for exemple, BUT instead of inserting tags I would like to put a link (ex. http://www.google.com) + name.
This link should go right to the end of my post content as a hyperlink with "Source: Name (hyperlinked by specified link)
Here is an example of what I am needing:
Title
This post is for example
Source: Google
Any help would be much appreciated. Thanks guys.
You can use the Custom Fields in Wordpress posts to add extre information to a post, then in your theme you can just grab the values. Here is what I use on my blog:
$custom_fields = get_post_custom($post_id);
if(!empty($custom_fields['article_source_url'][0]) && !empty($custom_fields['article_source_title'][0])){ ?>
<strong>Source</strong>: <?php echo($custom_fields['article_source_title'][0]); ?>
<?php }
Then in your wordpress post just add a Source URL and Title in the custom fields box:
You can use WP's Custom Fields to denote specific parameters for each page/post.
Then, in the template, just call them like this:
<?php
$custom_fields = get_post_custom();
var_dump($custom_fields);
?>
Note that they are arrays, so in case you have a field named URL, you'd need to call it like
echo $custom_fields['URL'][0];
This is done like this so you can have multiple values for the same field.
Also, in order to see the Custom Fields box, you need to go to the Screen Options (top right of the edit page) and enable them.
the website in question is right here I'm trying to generate a CSS dropdown, however no such option is available in wp_list_pages(), I also won't be able to get the desired effect using WP Menus in the appearance menu (I used this method to generate my footer links)
This is ideal:
I know how to generate the menu, I just don't know how to get it under the "cars" menu without a hack javascript solution.
The ideal solution involves targeting the list item by the template name "Car Showcase" and allowing me to generate PHP/HTML (The code needed to make the dropdown) after it. Does this make sense to everyone?
The actual way to create custom HTML for WordPress menu is to create a Walker
http://codex.wordpress.org/Function_Reference/Walker_Class
Can you not just create another menu and pull it from:
wp_nav_menu( array( 'name' => 'menu-header'));
I extended the walker class in functions.php, it was way dirtier than it should be, and I'm still targeting the list item being generated by an ID, a solution which I am not fond of, but this is the cleanest solution I can come up with until I find a better one.
class Dropdowns extends Walker_page {
function end_el(&$output, $item, $depth=0, $args=array()) {
if ($item -> ID == 55) { //checks if the page id is the list item I want to make my dropdown under
$vehicles = query_posts('post_type=vehicles'); //my custom post that I want to dropdown
if ($vehicles) { //check for no entries
//code for drop downs go here
}
}
}
}
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?