I'm using the vanilla Geneis theme with no child, but I cannot find where the logo should reside. I can change the favicon no worries, but I see no logo file present and I see no advice on how to add to the "parent" theme - I'm not using a child.
Is there a way to add a logo. I have changed the settings in wordpress for a logo rather than text (in the header settings). Any ideas?
Although I haven't done this on the default Genesis theme, I have replaced the main headline text with just a logo. I posted how I did it on the Genesis Forum, but here it is.
If you want to keep the rest of the genesis_do_header hook in place, you can just replace the default genesis_do_header using the child theme's functions.php.
Open up functions.php and add the following:
// Replace header hook to include logo
remove_action( 'genesis_header', 'genesis_do_header' );
add_action( 'genesis_header', 'genesis_do_new_header' );
function genesis_do_new_header() {
echo '<div id="title-area"><img src="your/logo/image.jpg" alt="Site Logo" />';
do_action( 'genesis_site_title' );
do_action( 'genesis_site_description' );
echo '</div><!-- end #title-area -->';
if ( is_active_sidebar( 'header-right' ) || has_action( 'genesis_header_right' ) ) {
echo '<div class="widget-area">';
do_action( 'genesis_header_right' );
dynamic_sidebar( 'header-right' );
echo '</div><!-- end .widget-area -->';
}
}
You can then style the image with your CSS in the following fashion:
#title-area img {
float:left;
}
You should now see your logo floated to the left of your site title. You may have to tweak some things, as the themes aren't identical, but let me know how this works for you.
Not to resurrect an old post or anything but I found a solution that works better than the one proposed above:
If you want to remove Title and Description then add following code in functions.php. This is useful when you decide to use site logo instead of text for site title.
/** Remove Title & Description **/
remove_action( 'genesis_site_title', 'genesis_seo_site_title' );
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
/** Remove default site title and add custom site title **/
remove_action( 'genesis_site_title', 'genesis_seo_site_title' );
function custom_site_title() {
echo '<img src="'.wp_get_attachment_url(254).'" alt="My Website"/>';
}
add_action( 'genesis_site_title', 'custom_site_title' );
Related
I want to remove only <p> tags without remove <br> tags in pages wordpress, i only found remove <br> tags and keep <p>, every i use remove_filter still remove <br> tags.
You can use strip_tags php function which removes php and html tags from a string.
This is for displaying the content: the_content()
https://developer.wordpress.org/reference/functions/the_content/
And this to retrieve the post content: get_the_content()
https://developer.wordpress.org/reference/functions/get_the_content/
(1) First way doing this: Change the page template of your theme
So in your page template, you normally will find the function call the_content().
But we need to retrieve the post content, remove the paragraph tags, and then display the "cleaned" content.
For that we will not use the_content() but use get_the_content().
<?php
$my_content = get_the_content();
$clean_content = strip_tags($my_content , '<p>');
echo $clean_content;
?>
We saved the post content in a variable (get_the_content is returning a string) and then used strip_tags to remove the tags. We just need to echo the "cleaned" content.
(2) Alternative way doing this: Change the output of the_content() function
If you want to use the_content() function or do not have the possibility to change the theme files, you can make use of the_content filter in wordpress.
function remove_tags_from_the_content( $content ) {
return strip_tags( $content, '<p>' );
}
add_filter( 'the_content', 'remove_tags_from_content' );
This way everytime your the_content() function is called, the filter will be applied so the function returns your cleaned version.
(3) Another way: Remove auto paragraphs in wordpress content
Wordpress adds paragraph tags to the content by default. You can disable this behaviour (remove the filter) by putting the follwing code in the functions.php file of your theme:
// Prevent wordpress from adding paragraph tags on pages
function disable_pages_wpautop( $content ) {
if ( is_singular( 'page' ) ) {
remove_filter( 'the_content', 'wpautop' );
}
return $content;
}
add_filter( 'the_content', 'disable_pages_wpautop', 0 );
You can replace the if condition with the post type you like:
if ( is_singular( 'your-post-type' ) )
If you want to remove the paragraphs in the content and excerpt in pages, posts and other post-types, you can get rid of the if-clause:
function disable_wpautop_all( $content ) {
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
return $content;
}
add_filter( 'the_content', 'disable_wpautop_all', 0 );
I have a related post code and I wants place it just after featured image on single post page. I have tried,
add_action( 'loop_start', 'wcr_related_posts', 10, 0 ) ;
but it doesn't work as I want to show content. It does show content at about proper place but the sidebar is not moving, just content is being shown a bit below and I also want the sidebar to come below due to code that wcr_related_posts generates.
I have not been able to find a hook that actually works that way I want it to.
You can do this using the 'the_content' filter:
add_filter( 'the_content', 'insert_featured_image', 20 );
function insert_featured_image( $content ) {
$content = preg_replace( "/<\/p>/", "</p>" . get_the_post_thumbnail($post->ID, 'post-single'), $content, 1 );
return $content;
}
Get the more details and examples as follow link : https://wordpress.stackexchange.com/questions/61272/how-do-i-add-the-featured-image-to-the-content-after-the-first-paragraph
The following site uses the Genesis Framework and a child them (if it matters) and I'm getting a weird issue with the grid layout for the blog archive page.
Here is the page: https://foralles.com/community/
It is skipping the first column in the second row. What is weird is it isn't doing this on the second/third/etc. pages of the archive.
In further weirdness, it isn't doing this in Chrome but is in FF, Safari and IE.
I've deleted the posts before and after the empty column and nothing changes.
This also wasn't happening until recently and I'm not sure what changed.
Given that it works in Chrome and on the subsequent archive pages makes me think it is some CSS issue but I can't figure it out...any help would be greatly appreciate.
Here is my code:
<?php
/**
* Template Name: Blog
* This is your custom Archive page for the Swank Theme.
*/
//* Show page content above posts
add_action( 'genesis_loop', 'genesis_standard_loop', 5 );
//* Add the featured image after post title
add_action( 'genesis_entry_header', 'foralles_grid' );
function foralles_grid() {
if ( has_post_thumbnail() ){
echo '<div class="archive-featured-image">';
echo '<a href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">';
echo get_the_post_thumbnail($thumbnail->ID);
echo '</a>';
echo '<a href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">';
echo the_title( '<h2>', '</h2>' );
echo '</a>';
echo '</div>';
}
}
//* Remove the ad widget
remove_action( 'genesis_before_loop', 'adspace_before_loop' );
//* Remove author box
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
//* Remove the post meta function
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
//* Remove the post info function
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
//* Force full width content layout
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//* Remove the entry title (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
//* Remove the post content
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
//* Add Page Heading and Content
add_action( 'genesis_before_loop', 'community_heading' );
function community_heading() {
?>
<h1>Community</h1>
<p>We built our Community page to share ideas, stories and inspiration. We’re sure you will find something that interests you and connects you to For Alles. Please enjoy exploring and reading. If there is anything you would like us to know please contact us. We’d love to hear what you think!</p>
<?php
}
genesis();
You need to use the min-height attribute. Edit the CSS as follows
.page-template-page_blog article.type-post, .archive article.type-post {
width: 33.33%;
float: left;
min-height: 450px;
}
This makes sure all the articles have a minimum height set, the problem arises when one item is bigger then another height wise and this takes up the area below it. This change can be made on the style.css file on line 881
I am using Wordpress and the Genesis framework for a site. I'm using a child theme (Ayoshop - not that it matters much) for the theme. I would like to customize the search results page by removing the 'post info' area where it shows the date, author, and 'leave a comment' link, and instead show the featured image for that post. The theme is using the search.php page from the Genesis theme, so I'm not really sure how to proceed in how to customize it.
Here is the code from the Genesis theme search.php:
add_action( 'genesis_before_loop', 'genesis_do_search_title' );
/**
* Echo the title with the search term.
*
* #since 1.9.0
*/
function genesis_do_search_title() {
$title = sprintf( '<div class="archive-description"><h1 class="archive-title">%s %s</h1></div>', apply_filters( 'genesis_search_title_text', __( 'Search Results for:', 'genesis' ) ), get_search_query() );
echo apply_filters( 'genesis_search_title_output', $title ) . "\n";
}
genesis();
It actually did matter that it was the Ayoshop theme, there was a custom filter that was added in a file called theme-tweaks.php that removed the original post info and added a custom post info, so I needed to remove that custom action.
All of the changes were done in the functions.php file.
I made sure to remove the genesis_post_info, and then removed the custom action that Ayoshop added.
remove_action( 'genesis_before_post_content', 'genesis_post_info' );
remove_action( 'genesis_before_post_content', 'ayo_post_info' );
I then added an action to add the image to the post.
add_action ( 'genesis_before_post_content', 'jl_post_info' );
function jl_post_info()
if ( has_post_thumbnail() ) {
printf( '<div class="post-info">' . get_the_post_thumbnail() . '</div>');
}
}
I've been trying to set the featured image as the background image on my blog. It's a single columned custom WordPress theme I am developing.
My idea is something like medium.com and blog.pickcrew.com
Can you guys please help me in getting it?
Thanks much!
You can try the following code snippet.
Save it to the file /wp-content/plugins/featured-image-background/featured-image-background.php and activate it:
<?php
/**
* Plugin Name: Featured Image Background
* Description: Featured image as background for single posts
* Plugin URI: http://stackoverflow.com/q/23388561/2078474
*/
function so_23388561_wp_head()
{
if ( is_single() )
{
if ( has_post_thumbnail( get_the_ID() ) )
{
$image = array_shift(
wp_get_attachment_image_src(
get_post_thumbnail_id( get_the_ID() ),
'full'
)
);
printf( '<style>
body {
background-image: url("%s") !important;
background-size: cover;
}
</style>',
$image
);
}
}
}
add_action( 'wp_head', 'so_23388561_wp_head' );
You might want to use another CSS selector than body, perhaps div#background?
In general I use get_queried_object_id() to get the post ID outside the loop, but get_the_ID() should work in this case.
We're using the wp_head hook, so make sure your theme has the wp_head() function.
Hopefully you can modify it to your needs.
You can try the following code
<?php $body_background = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); ?>
<body style="background-image: url(<?php echo $body_background['0'];?>)">
....
</body>