Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I know I have a static page for my home page in Wordpress. I also have a page called "Rate Entries" as my blog page. After showing this to my client, and then showing her the admin section of Wordpress, she began typing a paragraph into Pages >> All Pages >> "Rate Entries" >> Edit.
The big problem here, as you all know, is that if "Rate Entries" is my posts page, that page content does not show there, only the posts. Is there any way to add that page content to the top of the posts page? I had hoped to find a plugin to do this, but to no avail.
Assuming you've set a custom page for the posts in the Wordpress backend (Settings > Reading), you just need to add a few lines of code to your index.php file in your theme. Like so:
//grab the id of the page set in the backend
$posts_page_id = get_option('page_for_posts');
//grab the post object related to that id
$posts_page = get_post($posts_page_id);
//display the content if any
if( $posts_page->post_content ){
echo wpautop( $posts_page->post_content ); //uses wpautop to automatically add paragraphs
}
In your case, you can add the code to display the loop below this code.
Hope this helps!
Assuming you want a hardcoded paragraph at the top of entries page before the list of all entries, Why not create a template page, assign it to your rate entries page and hardcode your paragraph in the code so it's always on the top.
Read about page templates here
Update
Have you tried doing a sticky post? that should solve your problem
Here's what I've found that I had to insert into the index.php page in order to get what I need accomplished. Right before the loop that cycles through the posts as crowjonah had mentioned.
<?php $page = get_page_by_title( 'Rate Entries' ); ?>
<header class="entry-header">
<h1 class="etnry-title"><?=$page->post_title;?></h1>
<p><?=$page->post_content;?></p>
</header>
What this does is take the page title and content for the page, and place it right above where the posts spill out. This way, she can edit that text, and it will update on the posts page.
I solved this problem by using a text widget. By using a plugin called "Display widgets" I can make sure that this text only displays on the blog page.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm going to change the shop product title tag from H2 to H6. Please advise from which file these changes should be applied?
Summary:
sample.com/shop (this page)
h2-->h6
Update
As per your screenshot, you might want to do this using JavaScript/jQuery, since you're probably not using the default WooCommerce template. Hence, you can try the following snippet to achieve what you're looking for (I'm using jQuery here):
<script>
jQuery(document).ready(function(){
jQuery("h2.woocommerce-loop-product__title").each(function(
/* First we save the title */
$saved_text = jQuery(this).text();
/* Now we replace the tag */
jQuery(this).replaceWith("<h6 class='woocommerce-loop-product__title'>"+ $saved_text + "</h6>");
));
});
</script>
Note that I haven't been able to test the code. If you try this and it doesn't work or shows any issue, send me a screenshot and a small description of what steps have you taken to implement the code.
First, you need to create a child theme (if you don't have one already).
If you want to edit the shop page's title tag:
Then add a folder named woocommerce in the child theme.
Go to wp-content/plugins/woocommerce/templates and copy the archive-product.php file to your child theme's woocommerce folder.
Now, edit the archive-product.php file that is inside your child theme's woocommerce folder:
Find line 34 and change the tag to h6.
The current line looks like this:
<h1 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h1>
You'll change this line to this:
<h6 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h6>
In rare occasion, if this doesn't work, create a functions.php file in your child theme unless you already have it, and in it, add the following:
add_action('after_setup_theme', 's_my_custom_woocommerce_support');
function s_my_custom_woocommerce_support(){
add_theme_support( 'woocommerce' );
}
If you want to change the title tag of individual products:
In your child theme, create a file called functions.php unless you already have it and in it, add the following:
//First we remove the current title
remove_action( 'woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title', 10 );
//then we add our title
add_action('woocommerce_shop_loop_item_title', 's_woocommerce_change_product_title_tags', 10 );
//here we define how our title looks
function s_woocommerce_change_product_title_tags() {
echo '<h6 class="woocommerce-loop-product_title">' . get_the_title() . '</h6>';
}
Make sure you're adding the code inside <?php and ?>. Add these before and after the code if you're creating a brand new functions.php file.
However, please note that you can simply style the title using css classes and skip all these fuss, unless you absolutely need to change the tag (potentially for SEO or other purposes).
Is there a way my category archive display both full posts and excerpts?
What I want is the first two or three latest posts display as full content posts, and all the others as excerpts with just title and a read more button. These are displayed on one page. I am currently using a category archive, on the twentyfifteen theme.
I know I can set a page to either display full or just excerpts, but not a combination. Is this possible?
Thanks!
You can get these in your wordpress loop on page or post.
<?php
$content = get_content($post->ID); //full content of post
$excerpt = substr($content,0,150); //you can limit charaacter like 150
?>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have installed a slider plugin called Revolution Slider for my Kallyas theme. I need to add the php line code so that I get my slider working. Can anyone help about where should I exactly place that line?
There is a three ways to insert into the theme and the slider appears in your pages:
For all the pages: <?php putRevSlider( "slider_alias" ) ?>
For show only on homepage: <?php putRevSlider("slider_alias","homepage") ?>
For show on certain pages use: <?php putRevSlider("slider_alias","2,10") ?>. The numbers here are de ID of the pages.
Here the full documentation.
We would have to have see your header.php file / or see how the theme is structured in order to see where the best place would be to insert the PHP snippet provided by revslider.
Are you aware that you can use shortcode inside of your pages / posts instead of using the PHP snippet?
If it is to appear on every page you can add
to the header, footer or content pages (depending on where on the page you want to put it (and changing shortcodeXYZ to whatever the shortcode is).
This question already has answers here:
How to set character limit on the_content() and the_excerpt() in wordpress
(10 answers)
Closed 9 years ago.
I have a blog with posts, and I am using the quick tag to display summaries of blog posts in the /blog/ page. However, I would also like to show the two latest posts on the home page of my site, but only include a thumbnail, title, and first sentence.
I find that the quicktag is perfect for the blog home page, but too much text for home page. And if I place the quicktag where I want it, then the blog home page looks a bit silly and short on text.
Is there a way to use the_content(), the_excert(), or other function to just pull out the first "x" number of words or characters to display on the home page only?
This is a duplicate of How to set character limit on the_content() and the_excerpt() in wordpress.
From the answer:
You could use a Wordpress filter callback function. In your theme's
directory, create a file called functions.php and add the following
in:
<?php
add_filter("the_content", "plugin_myContentFilter");
function plugin_myContentFilter($content)
{
// Take the existing content and return a subset of it
return substr($content, 0, 300);
}
?>
The plugin_myContentFilter() function will be called each time you
request the content of a post/page via the_content() - it provides you
with the content as an input, and will use whatever you return from
the function for subsequent output or other filter functions.
I am trying to add a button to my WordPress template. Basically, I have the post and then there is the Related Posts Thumbnails widget that appears. I want the button to go between the text of the post and the related posts thumbnail widget. The code in my 'Single Post' that contains all of this is as follows:
<div class="post-content">
<?php the_content(__('<em><strong>More:</strong> Read the rest of this entry...</em>', 'life-is-simple')); ?>
</div>
I know the Related Posts Thumbnails plugin falls within this code because it's at that place when I 'Inspect Element' on Google Chrome. I can't find how to edit the order of things within that div though. Any help would be greatly appreciated, thanks!
EDIT
Clarification: I am using the Life Is Simple WordPress theme although it has been custom editing quite a bit (mostly on the CSS side of things though).
That plugin is probably appending the output to the_content with a filter .
That means , that the output is being added to the_content automatically. it is a common behaviour.
You need to look at the plugin´s admin interface to see if you can have an alternative way (I believe there is ) which is using a template tag. in that case, you should put the template tag after the div where the the_content() is .
EDIT I :
After a small dig, - in fact there is - you need to put
<?php get_related_posts_thumbnails(); ?>
Then the plugin should know by itself not to append to the_content.
For parameter passing, or if something is not working, go read their APi or help files.
You'll probably need to edit single.php or archive.php in your theme. If nothing is occuring there that looks familiar, it's probably using a loop. In which case you might find what you are looking for either in loop.php, loop-single.php, or loop-archive.php depending on what type of page you are on and how the theme was constructed. Add your button near where you find Read the rest of this entry...
With more information (such as what theme you are using), one might be able to help more as well.