I want to integrate specific text (text, links, images) making reference to specific sentences of my blog post.
Is it possible to do it with code or using a plugin ?
I send you a sketch :
This is the sketch
That is common need and often Aside in WordPress is talked for it. There are WP plugins like Aside Widget, Custom Sidebars for ordinary needs. But if you need too much custom stuff like my website's "About this Article" sidebar widget - https://thecustomizewindows.com/2016/09/limitations-of-openvz-virtualization-to-guest-cloud-server-vps/ then it is better to use
Otto's this plugin to use PHP in text widget - https://wordpress.org/plugins/php-code-widget/ and use PHP. In my case, rest is PHP code like this on sidebar (I can use shortcode too) :
<?php if(is_single()) : ?>
<h3>About This Article</h3>
<strong>Title:</strong> <?php echo get_the_title(); ?><br />
Published on: <?php the_time('Y-m-d') ?>
<br />
...
// rest of the code
<?php endif; ?>
Obviously you can call post image thumbnail with WordPress function.
As you need specific text, you may think about combining Pull Quote Plugin or Aside Widget to mark the specific like and echo it with PHP.
As other options -- you can use CSS3 to automatically select first line, first paragraph, second sentence. You can use Javascript to conditionally mark.
Best possible customisation I saw is on BMJ's sidebars. They use Drupal, not WordPress. BMJ has beautiful sidebar -- (as example) - http://www.bmj.com/content/355/bmj.i4924 Drupal has description of the work - https://www.drupal.org/node/1557636 Sadly I lack idea about Drupal. I tried a lot behind using WordPress for academic purpose.
Related
I have been building my first theme on WordPress and have run into problem while adding content into different sections.
My HTML is somewhat like this,
<div id="maintext">
<-- Text -->
</div>
<div id="products">
<-- Text and Images -->
</div>
<div id="about_company">
<-- Text boxes -->
</div>
How do I make sure the content added via the WordPress editor falls under the respective divs ? For the "maintext" div I'll load the content from the page itself but how do I add content to the other 2 divs dynamically ?
I searched on a couple of forums and many suggested to add content using widgets, is there any way it can be done without using widgets ?
Any help will be gladly appreciated.
Unfortunately adding multiple editable fields in a single page is not particularly easy using WordPress by itself.
Many WP devs I know (myself included) rely on the Advanced Custom Fields Plugin for additional content fields.
The steps to make this happen:
1) Install the ACF the plug.
2) In the settings area for ACF create some new fields.
3) Assign the new fields to appear for a specific page or set of pages.
4) Update your page-template for the given page(s) so that the new fields are displayed.
For instance you might create a set of standard wysiwyg fields and then assign them to the 'overview' page. Let's call these fields: main_text, products_info and about_company. Once the fields have been created and assigned to a page, when you edit that page the additional fields will be available to edit.
For these new fields to be seen by visitors, they must be added to the page-template you use for your overview page. The code could be something like this:
<div id="maintext">
<!-- Text -->
<?php if(get_field('main_text')){ //if the field is not empty
echo '<p>' . get_field('main_text') . '</p>'; //display it
} ?>
</div>
<div id="products">
<!-- Text and Images -->
<?php if(get_field('products_info')){ //if the field is not empty
echo '<p>' . get_field('products_info') . '</p>'; //display it
} ?>
</div>
<div id="about_company">
<!-- Text boxes -->
<?php if(get_field('about_company')){ //if the field is not empty
echo '<p>' . get_field('about_company') . '</p>'; //display it
} ?>
</div>
There are lots of good examples here. If you are feeling really ambitious, rather than install the plugin you could even include ACF directly in your theme.
You've got three options I believe:
Create a widget area where you can then display the content in a text widget: http://codex.wordpress.org/Function_Reference/register_sidebar
Create a template where you then get the content of a different page: http://codex.wordpress.org/Page_Templates#File_Folders
Create a new meta box for all your pages: http://codex.wordpress.org/Function_Reference/add_meta_box
I believe that the thing you are looking for is option 2. The others are more full-site oriented, if you want the extra content to show up on every single page.
If you are writing the theme, maybe you would like to consider using a WordPress Framework so you don't have to start from scratch.
If that is not the case, think of the end user. How will they add sections to pages and posts? Will they have to move across places within the WordPress UI, or would they rather user short codes?
My recommendation is to build a plugin that render the section within the document content. Or widget content if that is the case.
I wrote a little piece of code to illustrate how you can accomplish such a thing, and also because I kind of need it right now :D. You can find it on github here https://github.com/lionpage/Front-Office-Document-Sections
Hope this helps
<div id="maintext">
<?php the_content(); ?>
</div>
<div id="products">
<?php // echo wp function to get product data; ?>
</div>
<div id="about_company">
<?php // echo wp function to get about companydata; ?>
</div>
I've run into this issue several times now, and while the question is 3 years old, I think it's still rather current. I've succesfully used the Multiple Content Blocks plugin sometimes now:
https://ltz.wordpress.org/plugins/multiple-content-blocks/
After installing the plugin, you can just include the_block in your template:
<div id="maintext">
<?php the_content(); ?>
</div>
<div id="products">
<?php the_block('products') ?>
</div>
<div id="about_company">
<?php the_block('company') ?>
</div>
hi im currently developing a theme with that set up.
there are two ways to achieve this:
widgetized and fixed admin panel (customizer options)
i am using the two in my themes
if widgets
create a .php file that includes the widgets sections
create a widget for that section
if fixed in admin panel
you have to include the .php section in your functions.php
edit * advantage of widgetized is you can arrange them just like in a regular sidebar
Was struggling with this, and did not want to use a plugin. The only WordPress native option I found was to use Custom Fields. This works, but only for text, and is rather cumbersome.
The other non-plugin option is to simply use HTML in the WordPress editor, but this is of course far from ideal either.
Finally I gave up, and opted for the Advanced Custom Fields plugin as well.
I am trying to create a Wordpress site. The design is Here
I have created most of the outline of the site, barring the 3 regions "Follow Us", "Self Employment" & "Into Work Consortium".
The client has told me he would like to make those 3 regions editable.
My template contains an Index file, Header & Footer File as well as the obvious CSS files.
I am using the "Multi Edit Plugin" Multi Edit Plugin but that guide, does it so that you create a CustomPage. I guess I could do that but what I want is my index.php file to be added to the admin side of the site and then point the template there or similar.
As it's getting a little frustrating working with multiple WP plugins that just don't seem to do the job correctly.
There are many ways to go about this: one being what was mentioned by Pekka and the other using Custom Page templates.
The above mentioned methods are, in theory, quite similar with subtle differences in terms of execution and inclusion.
Perhaps to better answer your question, I will provide a very brief sample outline below on Custom Post Templates. You may probably need to do a little more digging at Wordpress' Codex if you choose to further enhance anything else:
Custom Post Template Method
Referring to the wireframe provided in your image link, I propose that you use category filters to filter the associated posts to the right columns. So first up, you will need to create 4 categories for the method that I'm suggesting, namely: WELCOME, FOLLOW, SELF-EMPLOYMENT and CONSORTIUM.
After doing so, your index.php should look something like this:
INDEX.PHP
<?php get_header();?>
<!--container-->
<div id="container">
<?php query_posts('category_name=welcome&showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<!--top-content-->
<div class="top-content">
<h2><?php the_title();?></h2>
<p><?php the_content();?></p>
</div>
<!--top-content-->
<?php endwhile;?>
<!--bottom-content-->
<div class="bottom-content">
<!--follow-->
<div class="follow">
<?php include(TEMPLATEPATH . '/follow.php');?>
</div>
<!--follow-->
<!--self-employment-->
<div class="self-employment">
<?php include(TEMPLATEPATH . '/self-employment.php');?>
</div>
<!--self-employment-->
<!--consortium-->
<div class="consortium">
<?php include(TEMPLATEPATH . '/consortium.php');?>
</div>
<!--consortium-->
</div>
<!--bottom-content-->
</div>
<!--container-->
<?php get_footer();?>
What is happening here is that I'm doing a post query for posts tagged to the category "WELCOME" and filter the posts into the top-content DIV. Note that my loop starts right before of the top-content DIV and ends immediately after it. This will means that the loop will only affect that particular DIV. I have also set the post limit to "1", thereby restricting the display of posts to just the latest post.
Following on from there, you will notice that in the bottom-content DIV, I have included 3 different files for each column. These 3 files will be your custom post templates that you will need to create and have a post query to filter in the right post. An example of the custom post template will look something like this below:
FOLLOW.PHP
<?php query_posts('category_name=follow&showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<h2><?php the_title();?></h2>
<?php the_post_thumbnail('bottom-content-thumb');?> <!--you will have to enable featured image thumbs in your functions.php file before you can do this-->
<span class="read-more">Continue Reading</span> <!--there are other ways to do the read more link, but I'm just giving an example now so yeah-->
<?php endwhile;?>
The rest of the custom post templates for the bottom 3 columns should look something like the above. If there is any variation of style and all, you will probably have to shift things around and play around with the CSS.
I want to stress that this is not the one and only way to do what you hope to achieve, but rather, that it is one of the many. What I've suggested is only an example that hopes to provide some insights on how you can utilize Custom Post templates for developing Wordpress based sites.
My advice at the end of the day is to delve deeper into Codex and find out more about Custom Post/Page templates because eventually, they will come in very handy if you choose to make custom Wordpress templates.
Hope my post had made things a little clearer for you =)
Hello i'm using widgets_on_pages to place widgets on pages, i installed it and added a widget to the panel in my admin section, then i added [widgets_on_pages id=2] ("its the 2nd sidebar and it said i should add this") into my html on the place where the widget should appear but it only shows the code i added in pure text, nothing else happens, anyone know what i'm doing wrong?
If I understand correctly then the following applies... if not, apologies.
You should not need to do it this way. It seems that Vincent, you are trying to add the shortcode into a theme php file... this is incorrect and the shortcode is for adding into the page/post content by the post/page editor.
To add a Widgets on Pages sidebar to a template then v 0.0.7 (I believe) has built in template tags (see link text). This should allow you to add the following I think
<?php widgets_on_template("2"); ?>
Try this
<?php echo do_shortcode('[widgets_on_pages id=2]'] ?>
I coudn't find the php that generates that or do I have to deactivate it from the Site admin?
You'll need to use your own callback for wp_list_comments() - check out Twenty Ten's comment callback twentyten_comment() as an example.
You'll see a line something along the lines of;
<?php if ( $comment->comment_approved == '0' ) : ?>
<em><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
<br />
<?php endif; ?>
You could pretty much copy and paste twentyten_comment() into your own theme, removing the block of code above, and then using wp_list_comments('callback=my_comment_callback') in comments.php.
Easiest way without cracking the code or bothering with a child theme is to hide it using css. In the theme I'm looking at now, that text is in a span tag assigned to the class "comment-await"
<span class="comment-await">Your comment is awaiting moderation.</span>
Most themes now offer a custom css option in the Customize section, so:
span.comment-await{display:none;}
You can play with changing the text by using css before or after selectors. Of course, you only want to do this for little changes, It it gets extensive the right way is to create a child theme and override the theme by editing comments.php (or other relevant file)
Download and Install Notepad++.
Open Notepad++
Hit "Ctrl-F" to get a Find dialog.
Change to the Find in Files tab ("Ctrl-Shift-F" might shortcut you here).
Change the filter to *.php
Change the location to your wordpress folder
Ensure you have Search in Subdirectories enabled.
Search for "Your comment is awaiting"
What's the best way to associate an image with a post in WordPress?
What I mean by that is when each post has a 'header' image which is not in the body of the post. You'd most likely use it to show a small image next to each post when they're listed somewhere.
I know you can use custom fields with posts, but are there any better ways of doing it?
Thanks in advance.
If you go the custom field route - in your template code you can save the value of the custom field to a variable and then echo it out to your image.
<?php $post_image = get_post_meta($post->ID, post_image, true); ?>
<?php if( $post_image != "" && isset($post_image) ) : ?>
<p><img src="<?php echo $post_image; ?>" alt="<?php echo $post_image; ?>" /></p>
<?php endif; ?>
<?php the_content('read more...'); ?>
The function the_content() may or may not be what you will end up using - for more control, you can try setting a new WP_Query() and then revamping the loop.
Not really any better way than custom fields, although you could always write out a unique class name containing the post ID on the container div and add the images via CSS each time you add a post. You'd end with a potentially huge CSS file though so I'd go for custom fields myself.
If you want a different image per post then use Customs Fields as suggested before - the only problem with that will be that Custom Fields are text fields and so you will have to upload your image and then paste the filename into your Custom Field. You could use the normal Add Image facility in the main post entry form but that will break up your workflow a bit as you will have to: upload the image in main post form, copy image url from HTML of form, remove image from form, paste URL into a custom field.
A bit of a pain!
If you want to use an image per category. Say, for example, you have a thumbnail for news items and a thumbnail for tutorials and so on. You could edit your WP theme template, check the category inside The Loop and show the relevant image from there.
The first option is a bit of a pain and the second requires some PHP coding.
A good way of associating an image with a post is to call the first image attached to that post in your template file.
I've elaborated a bit in this thread:
How would you recommend adding an image as a custom field in WordPress?