BuddyPress Title displays incorrectly - wordpress

I have my own theme and Buddypress installed on my Wordpress page but when I updated to the newest version (1.7.2) the titles of the BuddyPress pages display incorrectly (Profile page, Groups page, …): They show in a HTML form. On the twenty twelve theme everything looks good.
As an alternative I tried creating a new theme for BuddyPress (using the groups, members, … folders in my theme folder) but I found it too much of work to do. Isn't there a simple solution for only the title.
A screenshot of my groups title:
A screenshot how it is supposed to look:
<div id="page">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2 id="page_title"><?php the_title(); ?></h2>
<p id="author"><?php the_author(); ?></p>
<div class="content">
<?php the_content(); ?>
</div>
<?php endwhile; endif; ?>
<?php comments_template(); ?>
</div><!-- main -->

I used the "Remove private/protected from post titles" snippet from CSS Tricks in my functions.php. After I deleted it, it worked again.

Related

Wordpress the_content / post is empty

I'm building my own template for Wordpress and I'm bumping into an issue when displaying the content of a post.
I have already built one page template for the home page and it works fine. The loop outputs what I want to display. Now I'm building the template to display an article but the loop doesn't return anything.
Here is the code of the page template:
<?php
/*
Template Name: PAGE
*/
define( 'WP_USE_THEMES', false );
get_header();
?>
<div class="wrapper">
<div class="sidebar">
<?PHP get_sidebar(); ?>
</div>
<div class="main">
<div class="section group">
<div class="col col12-12">
<span>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</span>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
This results in displaying the "sorry, no posts matched your criteria" message when i click on one of the links on the homepage. The strange thing is that the page really exists (it has ID=26 as you'll see here below):
<?php
$post = get_post(26);
$title = $post->post_title;
echo $title;
?>
This works and displays the expected title. I have tried get_the_ID(); to get the post ID but it returns an empty variable.
There is probably something missing in my template but I can't figure out what.
Any idea?
Thanks
I have found the issue and it had nothing to do with the template itself.
I discovered what's wrong by using one of the standard Wordpress themes (twentyfifteen) where every post led me to a 404 even if I clicked on a post from the Admin UI. I swapped back permalink structure to the ?p=123 option and there everything working. Definitely a permalink structure problem.
The problem was coming from the polylang plug-in. I'm using a network of wordpress site for which I have made this plug-in available. I did not need this plug-in for this particular site but somehow it needed to be active anyway. So I activated polylang and configured it to have only one language and now it works.
Got new gray hair in the process but if that can help anyone...
Thanks for your help!
Laurent
I don't think, that this template can output any posts like this. For WordPress
/*
Template Name: PAGE
*/
indicates: this is a page-template which you can asign to the content of a page but not to a post.
When you want to show a specific post on such a page you will have to:
Asign the template to the page in WP-backend
Add a new query to the template to show the post
Like:
<?php
/*
Template Name: PAGE
*/
define( 'WP_USE_THEMES', false );
get_header();
?>
// The new Query
$args = array (
'p' => '26',
);
// The Query
$query = new WP_Query( $args );
<div class="wrapper">
<div class="sidebar">
<?PHP get_sidebar(); ?>
</div>
<div class="main">
<div class="section group">
<div class="col col12-12">
<span>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</span>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
But as this is very complicated I would recommend to:
delete the /* Template Name: PAGE */ from the template
save it as single.php or more specific as single-26.php
link to the desired post in your wp-menu

Wordpress: the_content() not showing

I installed a plugin called Admin Guide Dashboard Widget. The idea is that it adds a widget to the WordPress Control Panel (the first screen that shows up upon login). On this widget you choose a blog/post category and then every post you write with that category shows up in that widget.
Well it didn't work at all. The widget showed all of my posts. I tried to change the category on the widget, but I just couldn't get it to work so I uninstalled it. Then I realized the the_content() of all my blog posts was gone. I tried to install the plugin again, I tried to change the category I had set for the plugin, nothing worked. I uninstalled. The content part of my posts is still not showing up at all.
Before I installed that plugin I had only created one category, called "Nyheder"
Now I'm not sure if all of my posts were categorized as "Nyheder" or if they were simply uncategorized. I tried unchecking "Nyheder" from my posts but it gets checked again automatically. I don't know if my posts should be uncategorized (if that's even possible) or if the problem lies somewhere else.
The news archive page of the website in question is here. This page actually still shows the content. But if you click on a posts's title to go to its page, you will see that there is no content.
Here is the code on my single.php page, but I really doubt this is the problem.
<?php get_header(); ?>
<div id="pageHead">
</div>
<div id="main2" class="page clearfix">
<div id="content" class="threeFourth clearfix" style="width:100%;"><?php get_sidebar(); ?>
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?>>
<h1 style="display:inline;"><?php the_title(); ?></h1>
<?php
$page = $_SERVER['REQUEST_URI'];
if (substr($page, 1, 14) == "events_listing") {
echo "<h2>" . do_shortcode('[events-listing-date]');
if(do_shortcode('[events-listing-end-date]') != get_the_modified_date('d-m-Y') ) {
echo " til " . do_shortcode('[events-listing-end-date]') . "</h2>";
}
}
?>
<br>
<div class="meta clearfix" style="display:inline-block; padding-top: 10px; font-size: 14px;">
<?php _e('Skrevet af', 'themetrust'); ?> <?php the_author_posts_link(); ?> <?php _e('d.', 'themetrust'); ?> <?php the_time( 'j. F, Y' ) ?><br><br>
</div>
<?php edit_post_link(__('Edit Post', 'themetrust'), '<p>', '</p>'); ?>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
</div>
</div>
It looks like it had nothing to do with the plugin, but instead with another change I had made just before installing it. If you look at the code above, I defined a variable called $page. It turns out if I inserted the_content() before that it worked fine, but not after! So I changed the name of the variable to something else and put the_content() back in its place. Voila! I guess there was a conflict with the variable name $page and it somehow affected the_content().

Lightbox not working on Wordpress site

I am unable to get the Lightbox Plus Colorbox plugin to work on a wordpress theme that I am creating. I followed the steps to install the plugin -
Extract lightbox-plus.zip to your wp-content/plugins directory.
In the admin panel under plugins activate Lightbox Plus ColorBox.
In the admin panel under Appearance click on Lightbox Plus ColorBox to configure to your taste.
It should now be completely set up and functional
However, it is not functional. When I click on an image in a post, it takes the viewer to a new page. I'm completely stumped. My javascript is pretty weak and I'd love any help I can get to make this work!
<div style="background-color:#383838; padding:15px 0px; width:auto;">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="entry">
<h2 class="background_header"><?php the_title(); ?></h2>
<?php the_content(); ?>
</div>
</div>
<?php endwhile; endif; ?>
it is probably because you don't have the rel="lightbox[id|name]" to your img links.
In your theme, add this to your functions.php file.
to add the ID and separate them
add_filter('the_content', 'add_lightbox_rel');
function add_lightbox_rel( $content ) {
global $post;
$get_img ="/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
$img_replace = '<a$1href=$2$3.$4$5 rel="lightbox['.$post->ID.']" title="'.$post->post_title.'"$6>';
$content = preg_replace($get_img, $img_replace, $content);
return $content;
}

contents of page.php does not show in wordpress

I have updated my site on localhost and uploaded to server (000Webhost) then the contents of page.php(all other template as well) does not show anymore. However it still work fine on localhost. I thought something gone wrong in Wordpress on server so I have deleted database and recreate them and also reinstall Wordpress and then uploaded my theme but still not working. Does anyone know what is happening and what I am doing worng?? My page.php is very simple like this below, Oh the title is showing but not the contents.
<?php get_header(); ?>
<div id="content">
<h1 class="entry-title"><?php the_title(); ?></h1>
<p>
<?php the_content(); ?>
</p>
<div style="clear:both;"></div>
</div>
<?php get_footer(); ?>
here is the site.
http://ahi.webatu.com/?page_id=12
Thank you very much in advance!!
You need to be in the_post() scope to use the_content() function as you want
<?php if( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endif; ?>

custom wordpress theme echoes gallery short code

So i'm quite a beginner, trying to make a custom theme. In a page i want to have a gallery. Uploaded images, made a gallery all fine.
When I view the page it outputs only the shortcode:
[gallery orderby="post_date"]
my page.php file basically has:
<?php $content = get_page( $page_id ) ?>
<div id='content' class='shadow'>
<div id='innercontent'>
<!---page title-->
<?php echo "<h1>".$content->post_title."</h1><br>" ; ?>
<?php echo $content->post_content ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
I really don't understand how to get this to show correctly, any pointers would be greatly appreciated. Cheers, Matt
get_page returns the raw page data. There are a few ways to do what you want:
BAD WAY:
<?php $content = get_page( $page_id ) ?>
<div id='content' class='shadow'>
<div id='innercontent'>
<!---page title-->
<?php echo "<h1>".$content->post_title."</h1><br>" ; ?>
<?php echo do_shortcode($content->post_content); ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
do_shortcode() renders all registered shortcode that's found within a given string. In this case, your page's content will have all shortcode rendered before being written to the document. I say this is the "bad" way, only because it doesn't follow the usual Wordpress format. Which leads us to the:
BETTER WAY:
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<div id='content' class='shadow'>
<div id='innercontent'>
<!---page title-->
<h1><?php the_title(); ?></h1><br>
<?php the_content(); ?>
</div>
</div>
<?php endwhile;endif; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
This is what's called "The Loop". It is pretty much the standard for all Wordpress Themes in retrieving all Post or Page Data, as well as running queries against the database.
I would suggest getting to know it, as well as running Wordpress queries to modify the loop using WP Query. This is getting into a more complex area of Wordpress, but it will help you in the longrun with figuring out how to gather up all of the posts and pages you want to retrieve in your theme that aren't provided by Wordpress' globals.
Good luck.

Resources