I'm developing a wordpress theme, but I'm stuck in formatting the single.php.
I have in my posts a slideshow plugin which is load with the_content() function, togheter with the text of the post, and with the_title() load the title.
that seen like this:
<h1>the_title()</h1>
<div id=post>the_content</div>
the problem is, I need customize how it's display.
I need display:
<div>theplugin</div>
<div id=post>
<span>the_title</span>
the text
</div>
I try to do that with add_filters but I wasn't lucky.
I hope you can understand my explanation, if you need more details, just tell me.
Thanks in advanced.
If users can add plugin components to posts in the editor, they are usually added via shortcodes.
If that's the case with your plugin, you can add it with apply_filters(). Here's an example of how to add a slideshow from the popular nextgen gallery plugin outside the post content:
<?php
$slideshow = apply_filters('the_content', '[slideshow id=1]' );
echo $slideshow;
?>
The above code can be added into single.php, any static page's page template file or directly into header.php to display on all pages.
If you specify the plugin you're using, I'll update the answer accordingly.
If it should indeed be called directly via a function, I second Ancide's answer.
You just need to change the place of where the functions are situated. Like this:
<div>theplugin</div>
<div id=post>
<span><?php the_title(); ?></span>
<?php the_content(); ?>
</div>
Edit: I misunderstood the description of the problem. Here's my answer now that I understand what the problem is:
The plugin uses a hook for the_content function. If you look inside all the php-files inside wp-content/plugins/your-plugin there will be a file with this code:
add_action('the_content','some-function-name');
This tells wordpress to run the function some-function-name everytime the function the_content is run. So you need to look for the some-function-name to figure out how to customize the output.
Related
I need to add additional images next to post title, in this case decided to use ACF and add fields (image) into another plugin (Event Schedule). After I added fields in ACF I was trying to add some code from ACF documention however it doesnt work..
P.S. Every post will have different images based on their type. You can choose it while you are editing specific post.
In ACF field menu I chose to return format Image Array.
Tried with all return formats: Image Array, Image URL and Image ID. As I understand plugin cant find the variable acf_name and the image source is left blank.
<div class="wcs-class__meta">
<div class="wcs-class__inner-flex">
<h3 class="wcs-class__title" :title="event.title" v-html="event.title"></h3>
// Using this code from official ACF documentation
<?php
$acf_name= get_field('acf_name');
if( !empty($acf_name) ): ?>
<img src="<?php echo $acf_name['url']; ?>" alt="<?php echo $acf_name['alt']; ?>" />
<?php endif; ?>
</div>
</div>
Now nothing happens, no errors, nothing. However, also it doesnt show those images I want.
Files in the plugins folder do not have access to global functions like get_field();. You can overwrite most plugin files in your theme, in which you should have access to global functions. Keep in mind that when the plugin you override gets updated, the file your are overriding will not. This could cause security issues.
The following article talks about the right ways of custmizing plugins: https://iandunn.name/2014/01/10/the-right-way-to-customize-a-wordpress-plugin/
I am using woocommerce on my wordpress website and I want to merge the description and additional information tabs on the product pages. I want to place the content of both tabs underneath eachother. Note that there is a similar question (with answer) posted here: Merge Description and additional information tab in Woocommerce
However, this answer places the content of the tabs in two columns instead of underneath eachother. I tried using this answer and tweaking it in order to get the contents to show underneath eachother, but my knowledge of html and css is not sufficient enough to solve this problem (I am new to coding, and even though I am proud to say that I managed to do some edits and minor fixes, this problem is definitely out of my league...)
Is there anyone who could help me out?
Thanks in advance! :)
I found out a simple way to do this. (review would be great!) The content shown in description and additional information tabs is extracted from the database and displayed in these files:
theme/woocommerce/single-product/description.php
theme/woocommerce/single-product/additional-information.php
By copying the following code of additional-information.php to description.php the content of the two are merged into one tab.
global $product;
$heading = esc_html( apply_filters(
'woocommerce_product_additional_information_heading', __( 'Specification',
'rehub_framework' ) ) );
?>
<?php if ( $heading ) : ?>
<div class="rh-woo-section-title"><h2 class="mt0"><?php echo ''.$heading; ?
>: <span class="rh-woo-section-sub"><?php the_title();?></span></h2></div>
<?php endif; ?>
<?php do_action( 'woocommerce_product_additional_information', $product ); ?>
Hi everyone i want to hide date from my AD section (http://prntscr.com/lgsb8), i tried few CSS codes with inspect element but they seems to be not working.
Any one please check and provide me correct CSS code to hide or remove this from page.?
You can use nth-child to achieve this.
.short-features div:nth-child(3){
display: none;
}
Here you have some information about it, let me know if that helps.
You can change the date display in the theme editor by commenting out this code in your template:
<?php the_time('F j, Y'); ?> at <?phpthe_time() ?>
do this:
<!--<?phpthe_time('F j, Y'); ?> at <?phpthe_time() ?>-->
these will leave the code intact in case you ever want to put the date back in. As long as the code is commented out the date will not appear on the live page.
I created my event pages with a different website. That website generated an html page for me(with Javascript, CSS hosted at their end) each time I created an event. I would like to embed the event pages into my website. In order to achieve, I tried to create a blank page template like below:
<?php
/**
* Template Name: Blank
*
*/
if (have_posts()) {
while (have_posts()) { the_post();
the_content();
}
}
?>
Then pasted the content (including head and body) into WYSIWYG editor. However, WordPress pushes everything into body. How can I create a pure blank page template and have the ability to edit everything with WYSIWYG?
Not quite sure if this is the best way to solve your problem. If I understand correctly you want to include events from website X in a page on website Y?
Assuming you set up events as a custom post type, you could use an 'event' RSS feed on website X: http://www.website-x/feed/?post_type=event
Then, on website Y reed the feed using:
$content = file_get_contents('http://www.wesite-x/feed/?post_type=event');
$x = new SimpleXmlElement($content);
foreach($x->channel->item as $entry)
{
$title = $entry->title;
//ETC...
}
It's not wysiwyg but it well get you all the content you need, and you can do whatever you want with it.
Hope this helps.
I am updating my portfolio website and require a different sidebar for different ties of pages, i.e. one for work page and one for the blog page, apparently this can be done using Custom Fields in the page or post.
So, I opened up single.php and found the following code
<?php get_sidebar(); ?>
And replaced it with the code below
<?php $sidebar = get_post_meta($post->ID, "sidebar", true);
get_sidebar($sidebar);
?>
To add a custom sidebar, all I need to do now is apparently add the custom field “Sidebar” and include the name of the sidebar file. For example if I insert “page-01”, it will display sidebar-page-01.php as your sidebar.
After multiple times of trying however this 'isn't' the case, can't see anything wrong with what I am doing, any one have any ideas? Any help would be greatly appreciated!
Thanks guys!
You can do this the way you are doing it by doing your own php function and target the page you need with
<?php
if ( is_home() ) :
get_sidebar( 'home' );
elseif ( is_portfolio page1() ) :
get_sidebar( 'portfolio page sidebar' );
else :
get_sidebar();
endif;
?>
add more elseif statements for as many page & sidebar combination you will have
or you can download this plugin and use the code above the same way