I'm quite new to WordPress, and I'm trying to ease myself into it. I'm currently having a problem with the layout of posts.
One solution to a common layout problem is to require the user to put their content within separate divs within the WYSISYG editor. However, this is obviously not that user friendly.
One solution would be: when they create a new post, there are two separate WYSISWYG editors for that single post. One editor for images, one editor for text. This isn't exclusively a problem of separating images from text — more for separating content from content.
I'm not sure whether this would be with the functions.php or a plugin. I'd rather try and not use plugins if I don't have to.
Any information would be great.
Within the visual editor you can double click an image that you've included and within the advanced tab add your custom classes to it. WP also has alignleft, alignright and more classes for images. If my answer is off I think your question may need to be more pointed.
to solve your first, more specific issue regarding how to separate images from text (content).
As usual, there are many ways to achieve such result. I use this one:
As you may know, you can add images to every single post. The problem you certainly come up against is how to attach specific photos to a specific post without using a gallery placeholder inside the content (WYSISYG editor).
You can do so by uploading photos through "Add media" button. It is essential to "upload" those images to a post not to pick them from the media library. It is my understanding that without plugins this is the only way to genuinely attach images to a post.
The question arises how to get the attachment in your templates.
I use this generic function of mine written in functions.php to fetch attachments of a post:
function get_attachment($args) {
$defaults = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' =>'any', 'post_parent' => $post->ID);
$options = array_merge($defaults, $args);
return get_posts( $options );
}
Since you can upload other types of media (video, audio), there are examples how to use the mentioned function within your templates:
$gallery_images = get_attachment(array('post_parent' => $post->ID, 'post_mime_type' => 'image'));
$audio_files = get_attachment(array('post_parent' => $post->ID, 'post_mime_type' => 'audio'));
$video_files = get_attachment(array('post_parent' => $post->ID, 'post_mime_type' => 'video'));
To respond to your more generic question – separating content from content - indeed, you can alter the admin interface of "Add post form" by creating custom fields or meta boxes.
The help for creating meta boxes can be found in the Wordpress Codex, for instance here:
http://codex.wordpress.org/Function_Reference/add_meta_box
I hope it enlightens a bit.
Related
I'm trying to accomplish something that shouldn't be too difficult. However, I cannot get it right. The situation is as followed: I have a multisite with 2 subsites. All the 3 sites have their own custom post types.
I am trying to achieve the following: when a custom post type post is create on site ID = 3 using an ACF Frontend Form, this automatically creates another custom post type post on site with ID = 2.
Using the code below I am able to cross-post the posts from site A to site B. However now I only need to send the title through the Front-end form. The updated code can be found below:
add_action('publish_holiday', 'add_surf_holiday', 10, 2);
function add_surf_holiday($post) {
switch_to_blog(2);
/* the rest of the function code */
$labels = array(
'post_title' => $_POST['acf']['name_surf_accommodation'],
'post_status' => 'publish',
'post_type' => 'surf-holidays'
);
wp_insert_post( $labels );
restore_current_blog();
}
Does any of you have an idea how to solve this issue?
If anything is unclear, please let me know.
Hope to hear from you soon!
Cheers,
Hans
The issue maybe with where you have this code, and I'm making the assumption that you have placed it in functions.php and if so then you should remove it from there and then create a plugin with your code and Network Activate it. Have you tried this?
So - I've been running around ways to do this and get half way there which is a bit infuriating!
Using jetpack portfolio - I want to show normal categories in my blog section and posts, and jetpack project types on the portfolio page and single projects.
My current code looks like this - and shows the jetpack portfolio types for the first post on the archive-jetpack-portfolio, and display correctly on the single project. but doesn;t work at all for the blog posts.
<?php
if (is_page_template('page-blog.php','single.php','index.php' )){
wp_list_categories(array(
'show_option_all' => '',
'title_li' => '',
'separator' => '%20',
'orderby' => 'name'
));
} else {
the_terms($posts->ID, 'jetpack-portfolio-type');
}
?>
So if these pages - show this, else show this. I know the $post-ID is where it's falling over for the archive page. Don't know why the blog bit isn't working.
Hope that's enough to go on. I bow to your infinite knowledge hive-mind!
Depending on custom template you have created you will need to call for custom footer using get_footer function. Here you can read more about get_footer function. You just need to specify $name parameter.
Monika
My first post so I hope someone can help :)
I need to change http://designoriginal-test.co.uk/ef-travel/portfolio to http://designoriginal-test.co.uk/ef-travel/exhibitions
How can I go about doing this? There is no 'physical' page in the Wordpress backend so I am not able to change the slug manually.
Thanks in advance!
Zak
Looking at your site's source code I see body has classes post-type-archive and post-type-archive-portfolio, so it's not a taxonomy archive but a post type archive.
<body class="archive post-type-archive post-type-archive-portfolio nictitate-builder nictitate-header-style-1">
So, portfolio is a Custom Post Type. This allows two possibilities:
You're using a plugin to handle CPT's (eg: Custom Post Types UI).
In this case, you should have a submenu in your WP Dashboard where you could rename the post type.
Your CPT's are defined in your custom theme's (or custom plugin) source code
In this case, you should locate there (check your functions.php) some piece of code like this:
register_post_type( 'portfolio', … );
where you'll be able to rename the portfolio too.
In both cases I recommend you to backup your Database first. And if you're editing some source code files, backup them too before making changes.
Update:
After some research on the theme I've seen there's a free version of it. This version requires (via TGM Plugin Activation) a custom plugin from the same developer named Kopa Nictitate Toolkit.
function kopa_register_required_plugins() {
$plugins = array(
array(
'name' => 'Kopa Nictitate Toolkit',
'slug' => 'kopa-nictitate-toolkit',
'source' => 'http://downloads.wordpress.org/plugin/kopa-nictitate-toolkit.zip',
In this plugin they register the portfolio's CPT. So, check if you have this kopa-nictitate-toolkit folder in your /wp-content/plugins/. If so, there's a file named portfolio.php where they register the Portfolio CPT.
Edit:
You'll see that besides registering the CPT
register_post_type('portfolio', $args);
they also register some custom taxonomies.
register_taxonomy('portfolio_project', 'portfolio', $taxonomy_category_args);
register_taxonomy('portfolio_tag', 'portfolio', $taxonomy_tag_args);
You'll need to change this too so the theme won't broke. Check register_taxonomy docs.
Hope this helps!
Just go to the page and change the page name and its Permalink
I am working on a WordPress plug-in which automatically generates posts from a user´s facebook events (this is specifically for a single website, not trying to publish this).
So the post generating and "posting" really do work fine. I use php-class-html-generator for generating a posts mark-up. It basically looks like this:
$post_desc = HtmlTag::createElement('div');
$post_desc -> addClass("af_post_content");
$post_desc -> setText($event_desc);
...
$post = array(
'post_title' => $name,
'post_content' => $post_desc -> toString(),
'post_status' => 'publish',
'post_category' => $category_id
);
...
wp_insert_post($my_post);
When I look at the post´s mark-up (in the back-end or front-end) everything is alright.
Now to my problem: As these post represent "events" I want to add rich snippet mark-up to the post. Declare them as a event, add start time, location with postal address(https://schema.org/Event). The issue is, if I add the mark-up like this:
$post_desc -> set("itemscope", " ");
$post_desc -> set("itemtype", "http://schema.org/Event");
The "itemscope" and "itemtype" won´t show up in the post´s mark-up.
I tried this outside of WordPress with a single "hello world"-example to test if the php-class-html-generator is the issue, but it correctly generates the attributes.
<?php
require_once ('HtmlTag.class.php');
$post_desc = HtmlTag::createElement('div');
$post_desc -> addClass("af_post_content");
$post_desc -> set("itemscope", " ");
$post_desc -> setText("Hello world!");
echo $post_desc;
?>
Source looks like this:
<div itemscope=" " class="af_post_content">Hello world!</div>
So does WordPress suppress some attributes/tags in a post´s mark-up? I had a similiar problem when generating a <table> tag. If so, can I somehow allow these tags?
There are some plug-ins out there for rich snippets, but these mostly handle mark-up change when manually creating a post.
Thank you!
I wouldn't recommend any schema.org specific plugins, as these only bring noise. At least that was my experience.
Not sure if I can help for the specific problem you have, but you can at least try using Yoast plugin https://yoast.com/wordpress/, which is the SEO plugin that also manages schema.org markup in general.
I know it is not an out-of-the-box solution, but sometimes solutions that sound simple, like this one, may help.
i am developing a CMS site in wordpress ...
the final web page should some what look like :
Website
I want just one page (front page) and on that i want to display subpages titles in it. (About,Home,People)...
So when the subpage title is clicked it should expand and display the the page content in the panel,on same page and at same place.
any ideas regarding same?
Thanks in advance...:)
EDIT1
[accordions]
[accordion title="Accordion 1"]
Accordion 1 Content here
[/accordion]
[accordion title="Accordion 2"]
Accordion 2 Content here
[/accordion]
[accordion title="Accordion 3" last="last"]
Accordion 3 Content here
[/accordion]
[/accordions]
after puting the above code in the page content looks like this:
but on click of ACCORDION 1 its not getting expanded..
You can write your own template, which does a query (checks for a subpage), and adds its content between div tags.
When it's done, then it's time for JS/jQuery . Search for tab jQuery scripts, so you get some information.
Anyway, you will mostly need to use hide() / show() functions to reach something like that.
Also, did you made that template, and are you familiar with programming in WP?
<?php
$args = array(
'numberposts' => -1,
'post_parent' => $post->ID,
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'menu_order,title',
'order' => 'ASC'
);
$my_pagelist = get_children($args);
?>
Above is code for displaying subpage content, below is the jQuery tutorial for tabs.
http://jqueryui.com/demos/tabs/
EDIT:
Also, check this site - http://www.learningjquery.com/2006/09/slicker-show-and-hide it will show you some info about show/hide functions. Also more information about WP get_children function is found here - http://codex.wordpress.org/Function_Reference/get_children
If I understand your question correctly, in the latest version of WordPress.
Login to your admin panel.
Click on the 'Settings' tab, then the 'Reading' sub-tab.
Change the 'Front page displays' option to 'A static page'.