I need to hide the comments to non members in wordpress.
I don't know the function to I have to implement in the template. Maybe you can help me with this?
To be clear, the only thing I want to do is that only members can view comments posted.
Thanks.
If you are a litlle bit familiar with PHP you can have these blocks of code to block the comments displays for non logged users. Open the comments.php file or whatever file assumes that role.
You can add this line of code at the top of that PHP file:
<?php if (is_user_logged_in()): ?>
Then add the line below at the very end of the file.
<?php endif; ?>
I just spent two hours trying to do this, only to find an incredibly simple option that didn't need php. I'm using Live Composer, and my theme doesn't have a comments.php (and trying to create one didn't work - the site just ignored it). Here's what I did:
1) add a custom class to my comments element of .commentlist
2) add this to my style.css:
.commentlist {
display:none;
}
.logged-in .commentlist {
display:inline;
}
Related
I have developed my own custom theme for WordPress. Now recently I installed my theme under WordPress 3.9.1 and I have noticed a rather annoying message which appears on the second and third pages of my site. The message appears in the footer area. It does however not appear on the home page. The message conveyed is as following:
site name proudly powered by Wordpress Entries(RSS) and Comments(RSS)
Now one solution I have seen is to put the following into the style.css. however it does not work.
#site-generator{
display:none;
}
The second solution is to modify the footer.php file and remove a block of php code, now interestingly enough my theme does not contain a footer.php file. Just wondering is it some WordPress system file pushing out the message on my theme.
Any help greatly appreciated.
If you call get_footer() anywhere in your theme, but your theme doesn't include a footer.php, then a footer template is provided for you automatically:
If the theme contains no footer.php file then the footer from the default theme wp-includes/theme-compat/footer.php will be included.
This "theme compatibility" footer outputs a standard footer which includes the lines:
<?php printf(__('%1$s is proudly powered by %2$s'), get_bloginfo('name'),
'WordPress'); ?>
<br /><?php printf(__('%1$s and %2$s.'), '' . __('Entries (RSS)') . '', '' . __('Comments (RSS)') . ''); ?>
Which I'm pretty sure is where your "site name proudly powered by Wordpress Entries(RSS) and Comments(RSS)" will be coming from.
So, check your theme files for "get_footer()". If you don't have a footer.php, then you probably don't want to be using that.
However, it would be normal to include a footer.php so you can have standard footer code across all pages, for doing vital things like calling wp_footer() on every page, which is something you must do in a theme.
wp_footer is a standard hook point for plugins, themes, and WordPress itself to inject scripts, and anything else necessary, just before the closing of the HTML body, </body>. It's how the admin menubar gets output, for example, and often plugin Javascript. So you absolutely want it called at the bottom of every template, and providing a footer.php that does this (and closes your <body> and <html> tags, etc.) and including it from all of your template pages with get_footer() is the normal way.
If your current code works well and produces valid HTML while using the standard "compatibility" get_footer(), then personally, I'd add the bare minimum footer.php to your own theme:
<?php wp_footer(); ?>
</body>
</html>
Your CSS should probably say something more along the lines of
.site-generator {
display: none;
}
or if that doesn't work you could always do
.site-generator {
display: none!important;
}
What you have is missing the '.' which refers to the class 'site-generator'. It might also be an ID, in which case, it should look like
#site-generator {
display: none;
}
If you'd rather remove it from the theme, you could let me know what theme you're using, and I can take a look at where it is occurring in the theme.
I know this can be done only by making some changes on the file footer.php.If you can't find the footer.php file, look for another PHP file with "foot" or "footer" in the filename.
Just see a detailed explanation here.
If you're not using a footer.php file, the footer info must be in the bottom of index.php and page.php. My hunch is that the generator was removed from your page file, but not the index file. I would check that file and make sure the code isn't there.
If that doesn't work, you need to see what the css selector is surrounding the generator. If you right click on the sentence within your browser, you should get some sort of 'inspect element' option. (I use Chrome, but other browsers have similar tools.) Inspect the element and you should see some sort of class or id to target. It may be a
<div id="example">
or
<p class="example">
Find the id or class and modify your css, i.e.:
for an id:
#example {
display: none;
}
or for a class:
.example {
display: none;
}
If the generator is being added by an external source you may need to add !important.
.example {
display: none!important;
}
Good luck!
Another route would be copy the footer.php file in your theme's directory and paste it into a child theme. Open up the footer.php file in your child theme and delete the text with the sitename and powered by. It should be wrapped in php tags.
Easy! If your theme doesn't have a footer.php file (for example if you are creating a theme from scratch), create it and leave it empty. It will just disapear the annoying "proudly powered by..."
Example of theme/:
style.css // theme info
header.php // empty file <----
footer.php // empty file <----
index.php // file with wordpress loop, etc.
you can edit your theme in admin panel, (footer.php)
if you see an error on your homepage when you edit the footer.php you can use javascript to delete that. But first you should add tag with an id, then access that id in javascript like;
function myFunc(){
document.getElementById('id').innerHTML ="";
}
then edit your body tag like
<body onload="myFunc()">
How to add css to specific wordpress user to hide plugin fiction over front end? I installed the wp-about-author plugin but I need to set as hidden for admin user. So when the admin make any blog post then the wp-about-author wont be displayed. Unfortunately no feedback from the plugin developer. Thanks for any suggestions.
CSS way is not recommended since the user can check out actual DOM by view the source.
Instead, You can prevent from even showing up in the DOM Tree by modifying a plugin php file.
$level = get_the_author_meta('user_level');
if ($level == 10) {
return;
}
Add this line to wp-about-author.php on line #31.
This works, I tested.
Try to update plugin better then hack css :) You can add to wp-about-author.php on line #102 something like:
if (wp_admin()) $return_content = '';
I didn't check it, but might work for you.
How can I place a default text (hashtag) in the Custom Message?
The textarea is (located in line 643) under jetpack/modules/publicize/ui.php
I tried to put the text in front of $title in various ways, like:
<?php echo "#myhashtag $title"; ?>
or
<?php echo '#myhashtag '.$title; ?>
but it just echoes the text, not the $title.
Any ideas will be greatly appreciated.
You can use the approach of this Wordpress plugin i made (Publicize With Hashtags), which does exactly that. It basically use and action trigger bound to the 'save_post' native event.
If you want to develop your own one you can have a look at my Source Code on the project's GitHub page or in this installation & usage guide I wrote about it.
You can add a filter, like so, to your theme's functions.php or a site-specific plugin:
add_filter( 'wpas_default_prefix', 'add_default_publicize_hashtag_prefix', 10, 4 );
function add_default_publicize_hashtag_prefix() {
$default_tags = '#yourhastaghere ';
return $default_tags;
}
This will add your default hashtag before your title without you needing to hack the WordPress core.
jetpack/modules/publicize/ui.php itself states in its comments:
/**
* Only user facing pieces of Publicize are found here.
*/
You added your hashtag in the textarea which allows admins to enter a custom message (click edit and it will slide down with your hashtag).
As #Yazmin mentioned, the best way to permanently edit the message is using a filter. The filters available are wpas_default_prefix, wpas_default_message, and wpas_default_suffix.
Personally, I had no success using these filters and I'm interested in a working solution to this issue myself.
I am developing my own wordpress theme for very first time. I want that when admin login to WordPress, at top admin tool bar must be show on main front end of website.
I tried following things
if (is_user_logged_in())
{
show_admin_bar(true);
}#end if
in functions.php
What I believe that I missed some thing in header.php or index.php, but I am not sure.
The proper way to do this is with a filter in functions.php:
function my_function_admin_bar(){
return is_user_logged_in();
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');
The admin bar is called as part of the wp_footer() function, so you need to make sure you call that function in your footer section of the template:
<?php
wp_footer();
?>
A discussion of some specific issues that can cause this to break can be found here:
http://wordpress.org/support/topic/admin-bar-not-displaying
And finally, more details on how to use the show_admin_bar() in the functions.php file can be found here:
http://codex.wordpress.org/Plugin_API/Filter_Reference/show_admin_bar
How do I add a div between the header area and content area of a thesis theme. What is the code I need to write in custom_functions.php file to do this? If that's not the place, where do I need to make changes to get this done?
In your custom_functions.php file add the following code:
function my_div()
{
echo '<div>Some new DIV between the header and content</div>';
}
add_action('thesis_hook_after_header', 'my_div');
You my want to reference Thesis Hooks and the DIYThemes site for more specific Thesis help.
You'll need to edit the theme files. Probably the header.php and the one where the one which contains the body. Before you fire off questions like this, please read through http://codex.wordpress.org/Theme_Development.
One really easy way, is to use Thesis Openhooks. Select the one that's between the header and the content area. I use that method all the time, especially for images. Inside the hook, all you have to do is type the HTML code for the DIV (I tried to type it here, but the code disappeared after I posted the comment) and then I can add CSS code to it in custom.css. Hope this helps :)