I'd like to use a functions.php in my child theme to remove the blog title. Most posts here are for specific themes. No option I've tried have worked.
I found in header.php where the blog title is called:
<?php do_action('et_header_top'); ?>
<header class="clearfix">
<hgroup id="logo-area">
<?php $bloginfo_name = get_bloginfo( 'name' ); ?>
<h1 id="logo">
<?php if ( 'false' == et_get_option( 'flexible_logo_image', 'false' ) || '' == et_get_option( 'flexible_logo' ) ) echo apply_filters( 'et_logo_markup', $bloginfo_name ); else echo '<img src="' . esc_url( et_get_option( 'flexible_logo' ) ) . '" alt="' . esc_attr( $bloginfo_name ) . '" />'; ?>
</h1>
<h2><?php bloginfo( 'description' ); ?></h2>
</hgroup>
What do I put in functions.php to remove that?
I tried
`function remove_stuff()
{
remove_action('Fable_header','Fable_bloginfotitle',);
remove_action('Fable_header','Fable_bloginfodescription',);
}
add_action('init','remove_stuff');
?>`
with no change.
If you want to get rid of the blog title without deleting the code, you can comment it out. This helps reduce problems. If you want to put the blog title back later, you can easily put it out if it is commented out, but if you delete the text then you can't display the title.
Commenting out works like this: wrap your code in /* and */. Example: /* code */. In your case, you would want to comment out the code like this:
<?php do_action('et_header_top'); ?>
<header class="clearfix">
/* <hgroup id="logo-area">
<?php $bloginfo_name = get_bloginfo( 'name' ); ?>
<h1 id="logo">
<?php if ( 'false' == et_get_option( 'flexible_logo_image', 'false' ) || '' == et_get_option( 'flexible_logo' ) ) echo apply_filters( 'et_logo_markup', $bloginfo_name ); else echo '<img src="' . esc_url( et_get_option( 'flexible_logo' ) ) . '" alt="' . esc_attr( $bloginfo_name ) . '" />'; ?>
</h1>
<h2><?php bloginfo( 'description' ); ?></h2>
</hgroup> */
Related
Figured this would be pretty easy but I am running into an issue.
The website I am building, the client has a list of taxonomies that have an ACF Image Field and ACF Description field.
What they want to do is have a block where they can select certain ingredients from the Taxonomy Block, then have it render out formatted (on a page)(At this time it doesnt need to link to the actual category) but they want to do it this way so they dont need to update page by page when an ingredient changes description or image they can just change it in the taxonomy list.
Below is the code i am using to try and get it going from the docs, it wont render the name or original description it will render the slug but skips over the name but the slug is correct
I've been trying this with no luck, it just returns 3 li's which is correct but i can get a name or custom field to come through.
If i just the the_field('ingredients_selector'); I get the ID's just fine But for the life of me i can not get a term name or the ACF field attached to it/
$terms = get_field('ingredients_selector');
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<ul class="ingredients-list">';
foreach ( $terms as $term ) {
echo '<li class="ingredients-list__item">' . $term->name . '</li>'; ?>
<p>Description: <?php the_field('description', $term); ?></p>
<p>Image: <?php the_field('image', $term); ?></p>
<?php }
echo '</ul>';
}
?>
I've also tried this way, this gives me same reuslt but the slug with work, it will skip term name again but "view all" will link at least
<?php
$terms = get_field('ingredients_selector');
if( $terms ): ?>
<ul>
<?php foreach( $terms as $term ): ?>
<li>
<h2><?php echo esc_html( $term->name ); ?></h2>
<p>Term description: <?php the_field('description', $term); ?></p>
<p>Term Image: <?php the_field('image', $term); ?></p>
<p><?php echo esc_html( $term->description ); ?></p>
View all '<?php echo esc_html( $term->name ); ?>' posts
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Attached is my set up of the ACF fields
EDIT****
This was my solution
<?php
$tax = 'ingredients';
$terms = get_terms( $tax, $args = array(
'hide_empty' => false, // do not hide empty terms
));
foreach( $terms as $term ) {
$term_link = get_term_link( $term );
$image = get_field('image', 'ingredients_' . $term->term_id );
$description = get_field('description', 'ingredients_' . $term->term_id );
if( $term->count > 0 ) {
echo '<a href="' . esc_url( $term_link ) . '">';
echo '<img src="' . $image['url'] . '" alt="' . $image['alt'] .'">';
echo $term->name .'</a>';
echo $description;
} elseif( $term->count !== 0 ) {
echo '' . $term->name .'';
}
}
?>
Try this and replace term_name_ with your actual term slug:
<?php
$terms = get_field('ingredients_selector');
if( $terms ): ?>
<ul>
<?php foreach( $terms as $term ): ?>
<li>
<h2><?php echo esc_html( $term->name ); ?></h2>
<p>Term description: <?php the_field('description', 'term_name_'.$term->term_id); ?></p>
<p>Term Image: <?php the_field('image', 'term_name_'.$term->term_id); ?></p>
<p><?php echo esc_html( $term->description ); ?></p>
View all '<?php echo esc_html( $term->name ); ?>' posts
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
You can find more about this here.
An the bottom of the blog page of my WordPress site, there are numbers for pagination.
Assume my initial blog post page is https://example.com/blog
When I click number '2' to view more posts. My url changed as https://example.com/blogpage/2
However if i manually enter the url as https://example.com/blog/page/2 it goes to the second page of blog posts.
I only get this error when i am in page 1. When
I am in page 2 or page 3, the pagination links work fine
How can I correct this issue?
index.php file contains this code
<?php
global $wp_query, $wpl_exe_wp;
get_header();
get_template_part('part', 'breadcrumbs');
$style = $wpl_exe_wp->get_option('blog_archive_layout', 'system_layouts');
$read_more_text = $wpl_exe_wp->get_option('blog_read_more_text', 'system_layouts');
if( is_author() ) {
$style = $wpl_exe_wp->get_option('author_archive_layout', 'system_layouts');
$read_more_text = $wpl_exe_wp->get_option('author_read_more_text', 'system_layouts');
}
if( is_search() ) {
$read_more_text = $wpl_exe_wp->get_option('search_read_more_text', 'system_layouts');
if( get_query_var('post_type') == 'product' ) {
} else {
$style = $wpl_exe_wp->get_option('search_layout', 'system_layouts');
}
}
if( is_post_type_archive('wproto_portfolio') || is_tax( 'wproto_portfolio_category' ) ) {
$style = $wpl_exe_wp->get_option('portfolio_archive_layout', 'system_layouts');
$read_more_text = $wpl_exe_wp->get_option('portfolio_read_more_text', 'system_layouts');
}
?>
<section class="container" id="content">
<div class="row">
<div class="<?php echo wpl_exe_wp_front::content_classes( true ) . ' wproto-primary-content-area'; ?>">
<?php if( is_author() && $wpl_exe_wp->get_option('author_page_display_info', 'system_layouts') ): ?>
<!--
ABOUT AUTHOR INFO
-->
<?php wpl_exe_wp_front::about_author(); ?>
<?php endif; ?>
<?php if( is_post_type_archive('wproto_portfolio') || is_tax( 'wproto_portfolio_category' ) ): ?>
<!--
PORTFOLIO POSTS
-->
<?php echo do_shortcode('[wproto_portfolio read_more_text="' . esc_attr( $read_more_text ) . '" use_wp_query="1" posts_per_page="' . get_option('posts_per_page') . '" order_by="date" sort_by="DESC" style="' . esc_attr( $style ) . '" display_pagination="1" pagination_style="numeric_with_prev_next"]'); ?>
<?php else: ?>
<!--
POSTS
-->
<?php
$term_description = term_description();
if( $term_description <> '' ) {
echo wp_kses_post( $term_description );
}
?>
<?php echo do_shortcode('[wproto_blog read_more_text="' . esc_attr( $read_more_text ) . '" use_wp_query="1" posts_per_page="' . get_option('posts_per_page') . '" order_by="date" sort_by="DESC" style="' . esc_attr( $style ) . '" display_pagination="1" pagination_style="numeric_with_prev_next"]'); ?>
<?php endif; ?>
<div class="clearfix"></div>
</div>
<?php get_sidebar(); ?>
</div>
</section>
I am trying to make a function which take an rss fedd URL and fetches the most recent 2 posts. I have tried to remake the snippet from here to a full function in funtions.php as following. I don't want to use a plugin for this since the plugins I have looked at have been close to impossible to style with my own html...
function fetch_feed_from_blogg($path) {
$rss = fetch_feed($path);
if (!is_wp_error( $rss ) ) :
$maxitems = $rss->get_item_quantity(2);
$rss_items = $rss->get_items(0, $maxitems);
endif;
function get_first_image_url($html)
{
if (preg_match('/<img.+?src="(.+?)"/', $html, $matches)) {
return $matches[1];
}
}
function shorten($string, $length)
{
$suffix = '…';
$short_desc = trim(str_replace(array("/r", "/n", "/t"), ' ', strip_tags($string)));
$desc = trim(substr($short_desc, 0, $length));
$lastchar = substr($desc, -1, 1);
if ($lastchar == '.' || $lastchar == '!' || $lastchar == '?') $suffix='';
$desc .= $suffix;
return $desc;
}
if ($maxitems == 0) echo '<li>No items.</li>';
else
foreach ( $rss_items as $item ) :
$html = '<ul class="rss-items" id="wow-feed"> <li class="item"> <span class="rss-image"><img src="' .get_first_image_url($item->get_content()). '"/></span>
<span class="data"><h5><a href="' . esc_url( $item->get_permalink() ) . '" title="' . esc_html( $item->get_title() ) . '"' . esc_html( $item->get_title() ) . '</a></h5></li></ul>';
return $html;
}
I am also trying to make it so that it can be used several times on a single page.
Much easier to use WordPress's built-in RSS function. See https://codex.wordpress.org/Function_Reference/fetch_feed
Use it as many times as you want in a php template, or make it generate a shortcode. Style the <ul> and <li> and add a containing <div> if needed.
Example:
<?php // Get RSS Feed(s)
include_once( ABSPATH . WPINC . '/feed.php' );
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed( 'http://example.com/rss/feed/goes/here' );
$maxitems = 0;
if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity( 5 );
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items( 0, $maxitems );
endif;
?>
<ul>
<?php if ( $maxitems == 0 ) : ?>
<li><?php _e( 'No items', 'my-text-domain' ); ?></li>
<?php else : ?>
<?php // Loop through each feed item and display each item as a hyperlink. ?>
<?php foreach ( $rss_items as $item ) : ?>
<li>
<a href="<?php echo esc_url( $item->get_permalink() ); ?>"
title="<?php printf( __( 'Posted %s', 'my-text-domain' ), $item->get_date('j F Y | g:i a') ); ?>">
<?php echo esc_html( $item->get_title() ); ?>
</a>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
Current theme is set up to generate a thumbnail based on user input (variable height). I would like to have this thumbnail link to a full size featured image via prettyphoto. Current code calling generated thumb:
<?php
//if our user has a post thumbnail
//out featured image URL
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
?>
<?php if($src[0] != '') : //if user has featured image ?>
<img src="<?php echo ddTimthumb($src[0], $contentW, get_post_meta($post->ID, 'postThumbHeight', true)); ?>" alt="<?php the_title(); ?>" />
You can use this just modify the classes and other attributes according to your need.
<?php
if ( has_post_thumbnail()) {
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
echo '<a rel="prettyPhoto" href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >';
the_post_thumbnail();
echo '</a>';
}
?>
I am actually using this same thing in one of my project see the code link and see if that can help you :) and once again don't expect it to work by copy pasting this is just to give you an idea modify it to your needs :)
Link to pastebin for code sample (or see below)
<div class="row" id="gallery-main">
<?php $args = array(
'post_type' => 'portfolio',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1,
);
query_posts($args); if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="span4 portfolio-item">
<?php
if ( has_post_thumbnail()) {
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
echo '<a class="image-link pi-img" rel="prettyPhoto" href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >';
the_post_thumbnail('portfolio-listing');
echo '<div class="hover-style"></div></a>';
}
?>
</div>
<?php endwhile;endif; ?>
<?php wp_reset_query(); ?>
</div>
I recently tried the previous post and the next post button link. I do that with image in the left and right side of the site.Its working perfect.But i didn't know how to do this
For Example:
<div class="alignleftfp">
<?php next_post('%', '<img class="imgalign" src="' . WP_CONTENT_URL . '/uploads/1.png" alt="Next" /> ', 'no');
?>
</div>
<div class="alignrightfp">
<?php previous_post('%', '<img class="imgalign" src="' . WP_CONTENT_URL . '/uploads/1.png" alt="Next" /> ', 'no');
?>
</div>
Is it Possible to Show the Previous Post and Next Post Link with Under Title in every Bottom of the Post. Here is the Screenshot.
<nav id="nav-single">
<?php
$prev_post = get_previous_post();
$id = $prev_post->ID ;
$permalink = get_permalink( $id );
?>
<?php
$next_post = get_next_post();
$nid = $next_post->ID ;
$permalink = get_permalink($nid);
?>
<span class="nav-previous"><?php previous_post_link( '%link', __( '<span class="meta-nav">←</span> Previous', 'twentyeleven' ) ); ?>
<h2><?php echo $prev_post->post_title; ?></h2>
</span>
<span class="nav-next"><?php next_post_link( '%link', __( 'Next <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?>
<h2><?php echo $next_post->post_title; ?></h2>
</span>
</nav>
I hope you are using this code in single.php from where the whole of the post is displayed. For displaying the links (Next/Prev), you need to check the function.
get_template_part()
in the same file (Single.php of your theme). In my case function in single.php has been passes parameters like
<?php get_template_part( 'content-single', get_post_format() ); ?>
So, you will open the "content-single.php" according to the parameters specified in the function and paste the same code
<div class="alignleftfp">
<?php next_post('%', '<img class="imgalign" src="' . get_bloginfo('template_directory') . '/images/1.png" alt="Next" /> ', 'no');
?>
</div>
<?php previous_post('%', '<img class="imgalign" src="' . get_bloginfo('template_directory') . '/images/2.png" alt="Next" /> ', 'no');
?>
</div>
below <h1 class="entry-title"><?php the_title(); ?></h1>
I hope this will solve your problem.