I have a wordpress website which I've added a couple of custom pages to. Everything works fine except that those custom pages don't have titles. Is there a (short?) way to add titles to those custom pages?
Edit: I think I was unclear, I meant the title at the top of the browser (html title) not the title of a wordpress page.
You can go to the 'Pages' page where it lists the pages and use quick edit:
Hover over a page and click 'Quick Edit'
Make your changes, and then click 'Update'.
EDIT
I seem to have misunderstood the question. Yes, WordPress gives you a filter to play with the title. See below:
function my_title_tag_filterer( $title, $separator, $separator_location ){
//You can do things to the title here.
return $title;
}
add_filter( 'wp_filter', 'my_title_tag_filterer' );
$title is the title, $separator is the text that goes between the blog title and the page title, and $separator_location is where the separator goes in relation to the page title.
Related
How can I rewrite meta title and description in Wordpress using child theme functions.php?
I want to rewrite it only on main blog page (for example: www.example.com/blog), where I have listed all articles.
The problem is that the main theme already adds title and description to blog page. So I need to remove them first and then add custom ones.
Thank you very much for your help.
First off, WordPress does not add a <meta name=decription> tag. That is usually done by a seo plugin like Yoast, therefor the method for overriding it differ per plugin. Or theme.
You might be a able to change these texts in the wp-admin settings, again depending on the plugin/theme.
The title you should be able to change using this example:
function SO_52811727_wp_title($title) {
// see https://codex.wordpress.org/Conditional_Tags for more options
if ( is_archive() ){
$title = 'custom title';
}
return $title;
}
add_filter('wp_title', 'SO_52811727_wp_title', 100);
I have a customized admin where I have changed posts to "articles" and I changed this text throughout the rest of the site by adding some code to functions.php but can't find a way to alter it in the dashboard widget that, the main default one that is titled "Right Now." I'd like it to say "X Articles" instead of "Posts" here. Anyone know? I'd like to change "X Categories" to a custom taxonomy and eliminate the listings for tags and pages from this space as well.
Any help is greatly appreciated.
Looking at the core, I see the string is hardcoded. Two ways to change it: jQuery or the filter get_text.
You'll want to load it only in that specific page, so use:
add_action( 'load-index.php', 'callback' );
function callback()
{
// add_filter( 'get_text', etc...
# OR
// add_action( 'admin_footer', print jQuery...
}
Here's another example of usage.
http://www.mytwins.gr/site/
In the third blog post you will see that a shortcode shows up [frame align="none"]Της Εύης Σταθάτου[/frame] which is ugly. Only if you click it, it works fine.
Why is that?, How can you hide the code from the previews posts thingy? Thanks in advance.
P.S I tried to hide the shortcode from the visual mode and enter it in the text mode, but still the same.
As #Ravi suggests, make sure that your plugins are enabled. However, it looks like your shortcodes are appearing within your excerpts (assuming you're using the_excerpt() for the snippets appearing on your homepage?)
I would suggest a handy snippet of RegEx:
$myExcerpt = get_the_excerpt();
$myExcerpt = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $myExcerpt);
echo $myExcerpt;
That should stop the raw shortcodes from appearing.
I have generated pages using a custom template by creating a php file in my theme directory
something like :
<?php
*
* Template Name: Contact Page
*/
?>
<html ..... </html>
and then adding a new page on the dashboard selecting this new template
How can i now associate tags and categories to each pages ?
Is creating posts instead of pages the only solution?
Even better is to add to functions.php in your theme folder:
function myplugin_settings() {
// Add tag metabox to page
register_taxonomy_for_object_type('post_tag', 'page');
// Add category metabox to page
register_taxonomy_for_object_type('category', 'page');
}
// Add to the admin_init hook of your theme functions.php file
add_action( 'init', 'myplugin_settings' );
Tried using the accepted answer but for some reason it only shows the Post types and none of the Pages shows in the category page. E.g. /category/entertainment/
To fix that, I have to do this:
// add tag and category support to pages
function tags_categories_support_all() {
register_taxonomy_for_object_type('post_tag', 'page');
register_taxonomy_for_object_type('category', 'page');
}
// ensure all tags and categories are included in queries
function tags_categories_support_query($wp_query) {
if ($wp_query->get('tag')) $wp_query->set('post_type', 'any');
if ($wp_query->get('category_name')) $wp_query->set('post_type', 'any');
}
// tag and category hooks
add_action('init', 'tags_categories_support_all');
add_action('pre_get_posts', 'tags_categories_support_query');
Try this:
add_action( 'init', 'wpse34528_add_page_cats' );
function wpse34528_add_page_cats(){
register_taxonomy_for_object_type('post_tag', 'page');
register_taxonomy_for_object_type('category', 'page');
}
Not at all helpful to say 'download plugin' for beginners who are most likely not going to have downloaded wordpress and are therefore not able to install said plugin. Here is some short code for those like me that have been scouring the web for something that actually works on regular pages with regular accounts - ie you're not a developer.
First, make sure you have your pages in your menu set up properly.
YOU DO NOT NEED TO MAKE YOUR PAGES 'Categories' or 'Tags'!
This wouldn't give you actual pages to then go and edit, so if you are wanting to add sliders, text, an intro, or anything for that matter, you wouldn't be able to.
Then go to WP Admin > Pages
Select a page to edit and go to the text editor instead of visual editor (far right hand side tab)
Then past the following short code:
[display-posts category="hair,makeup,reviews,beauty" posts_per_page="10" include_date="true" text-decoration: none date_format="F j, Y" order="DESC" include_excerpt="true" wrapper="div" image_size="large"]
<
(The shortcode collects all the posts that you have assigned certain categories in your blog posts i.e. mine was hair and beauty. So obviously change yours to ones that are appropriate. It then allocates how many posts (mine was 10), the date (in descending order,) with a large image and an excerpt of the post)
this plugin sorted me out :
http://wordpress.org/extend/plugins/add-tags-and-category-to-page/
with the standard instructions :
Upload the plugin files to the /wp-content/plugins/ directory
Activate the plugin through the 'Plugins' menu in WordPress
Use the setting page of the plugin from Settings > Add Tags And Category For Page.
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.