Is there a way in a Wordpress blog to get the admin side of Wordpress to add custom content in the database, that will not be anything related to posts or pages?
It will just be a little bit of info such as date, title, description, and an image that I will use in a specific part of the front page.
Is wordpress too restrictive on this, will I have to use a different CMS?
Edit:
Could Custom Post Types be what I am looking for?
"It will just be a little bit of info such as date, title, description, and an image that I will use in a specific part of the front page."
So, if I am reading this correctly, you want to create a custom post type, which describing what you are saying - "date, title, description, image" - this is basically a post ;)
You can easily hook into the wordpress query object.
E.g.
$args = array(
'post_type'=>'my_special_post',
'posts_per_page'=>8
);
query_posts($args);
The the normal while posts applies. If you don't want it to be in within the post array, then nothing is stopping you from just creating your own queries which is well explained here: http://codex.wordpress.org/Custom_Queries.
I should add creating post types as well - they are easily configured in your functions.php file without need to add a plugin. Unless you want a more managed solution: http://codex.wordpress.org/Post_Types
You should store these values in custom fields.
Recent WP releases fully support custom types: http://codex.wordpress.org/Post_Types#Custom_Types
This allows you to create a new, full-class data type that will have a new menu option below post and page.
Also, take a look at the More Types plugin (http://wordpress.org/extend/plugins/more-types/), which provides an easy and powerful GUI for doing this. Along with More Fields by the same author (http://wordpress.org/extend/plugins/more-fields/), WP becomes a pretty powerful CMS.
Related
I am running WordPress 4.5.2, Twentysixteen, and a plugin called 'Custom Fields Template'. I am looking to make the most of WordPress' custom fields but do not know how to make it do more than display a UL with some basic text data.
I would like to know how to:
display an image (from Media Library),
an active link, and
an active link to a media file (e.g. Download PDF Brochure).
I like the 'Custom Fields Template' plugin as it was super easy to install, set up with the variables I need, is clean and lightweight. Here are some screenshots of what I've got so far (for a racehorse syndication website - not live):
This is the Custom Fields Template within WordPress' page edit screen.
This is the resulting code - prints image ID only.
I am comfortable with modifying WordPress's .php files but am not fluent enough with PHP to write the necessary functions from scratch.
Any help would be greatly appreciated.
Since you don't provide enough specifics I can only write a very generic answer.
The function the_meta() you found does not belong to the theme, it is provided by the WordPress core and as you already noticed is not very customizable, it's output can only be styled with CSS.
I assume this is the plugin you are using: https://wordpress.org/plugins/custom-field-template/
Based on that assumption you have these possibilities:
The plugin provides the shortcode [cft] you can use in the content of the post itself. It's usage is described a little bit in the plugin description, but not much.
If know that you want to show this on every post or every certain post type you can create a template file for this and call the shortcode directly using do_shortcode().
echo do_shortcode( "[cft]" );
If you don't like the output of that shortcode either, you can address the custom fields directly.
It looks like the plugin doesn't show you the field names it actually uses, so you need to find them yourself. You can do this either by looking at the database, you'll find them in the table wp_postmeta, or you add some debug output to your template file, like this:
$meta = get_post_custom( $post->ID );
var_dump( $meta );
This will show you all custom fields from the current post. You can then either use this array to print your values, or you use get_post_meta() to retrieve specific field values.
Last, but not least: You stated that you are using the default theme Twentysixteen. You should NOT edit any of these theme files, or the files from the custom field plugin. The next time they are updated all your changes are going to be lost. Instead, create a child theme and add your post templates there.
I've just come across this very helpful article for beginners - it broke down the steps I needed to take to achieve what I was after:
https://perishablepress.com/wordpress-custom-fields-tutorial/
This is the Download & Print Brochure link I ended up with (using any custom field data i.e. with and without the plugin).
<?php $imageid = get_post_meta($post->ID, 'Brochure', true); ?>
Download & Print Brochure
Alright I am completely lost on how to do this so I am just going to throw the question out there and hope somebody can help me in some way or another.
WordPress offers the option to create custom Taxonomies so I got the idea of pulling something out of my hat and creating a custom content section apart from the content section wordpress currently offers.
The website shown above is the only website I have been able to find which currently does this and is on a WordPress platform, as you can see they have the SoundCloud audio player pushed over to one side with the actual content placed to the other side creating that flawless look.
I guess the question here is how can I turn <?php the_content(); ?> into something completely custom pulling from a completely different form in the back end so the same information is not shared.
There are numerous ways to achieve what you want.
Shortcodes
Custom page templates
Custom meta fields to store values like the soundcloud embed url, to afterwards use it in your code.
You can always also enter HTML in the page editor, but for obvious reasons not recommended.
Custom post types allow you to define a new type of content. It will have its own section in admin where you add and edit data separate from normal Wordpress posts. It can have its own templates allowing different layouts, and you can set up custom fields so that it can store different data.
I also recommend taking a look at the Pods Framework. This plugin allows you to define custom content types very easily in the admin interface. You can set up all your fields and data types from there. All that's required then is to create the templates to make it look nice.
The nice thing about these approaches is that while the data is kept separate from standard Wordpress posts, you still have the same familiar UI, so it's easy for none-technical users to update the content.
I am creating my first wordpress plugin. In it, the user will have the option to add new cities and view events on those cities.
My client requirement is that the URL must be like this
SITE_NAME/cities/NY
or
SITE_NAME/cities/Califonia
What is decided is that i will create a folder cities and If user tries to create a new city i will create a file in that folder with that city, Further more I will add the entry into the database as well.I will insert PHP code into the file as well.
Being new to WP plugins. Is my approach right (for creating files)? Is there any other way?
Your approach would work if you WEREN'T using Wordpress, but I would absolutely not advise doing what you're suggesting within the Wordpress Framework.
Rather than trying to reinvent the wheel, just about everything you want can be achieved with existing Plugins. I would absolutely suggest taking this route, especially if you don't have much experience with programming Wordpress Plugins.
Step 1:Install Wordpress
Self-explanatory. Can't do anything without this.
Step 2:Install Types
Installing the Types Plugin will give you a nice interface for registering your own Custom Post Types and many other features for extending Wordpress' core capabilities.
Step 3:Register your Custom Post Type
This is where things start to get complicated. Using Types, Register a Custom Post Type called Event. The reason why you want to have each event as its own Post is because each Event is unique. Cities are meant to encapsulate and define groups of events, which brings us to our next step:
Step 4:Register your Custom Taxonomy
Think of a Taxonomy as a way to classify things. Wordpress comes with two default Taxonomies: Categories (hierarchical) and Tags (non-hierarchical). In your case, you will want to define for your new Event Post Type a non-hierarchical Taxonomy called "Cities".
Step 5:Register your Custom Fields
Custom Fields are the easy part. What defines your event? Maybe some fields that define the start and end times of that particular event? A checkbox denoting free refreshments? The sky's the limit. What defining characteristics would all Events have that makes it an Event? Add those in the form of Custom Fields. These will show up on your Event Editor in the form of Meta Boxes. If you don't see the Meta Boxes on the Edit Page for a particular event, be sure to enable it by clicking Screen Options in the upper-right-hand corner of your screen and ticking the checkbox where your fields would be located.
Step 6:Configure your Permalinks
Much of this can be done either through Types itself (when configuring your Custom Taxonomy), or through .htaccess rewrites, or perhaps even through the Wordpress Permalinks Settings (though, it's fairly limited). My suggestion is to tweak your Custom Taxonomy and Permalink Settings first before messing with .htaccess.
And that's it! Hopefully this should be enough to get you started on everything you need.
maiorano84 wrote a fairly comprehensive guide to setting up the stuff you need, Rather than relying on plugins though, I prefer to show you how to write a plugin to register the custom post type and taxonomy. To that effect, I wrote a little plugin that should do everything you need and it has plenty of comments and links to the docs so that you can understand the Why of things.
Code
https://github.com/fyaconiello/WP_Cities_Events
This plugin does several things
Creates a custom post type Event
Creates a custom taxonomy City
Adds custom metaboxes to Event
Adds City taxonomy to Event
This plugin does not require any additional plugins to be installed, it is dependency free and only uses WP core.
URLS
As far as getting the correct URL Structure, I would suggest you read this thoroughly: http://codex.wordpress.org/Using_Permalinks.
I do not understand the structure you want
CITY is a single term w/i the taxonomy *cities*
EVENT is the post single
SITE_URL/cities/CITY would yield a page of all EVENT posts in that CITY
you need a url like: SITE_URL/cities/CITY/EVENT to read a specific event in a specific city
EDIT on how to urls:
In your Settings -> Permalinks administration panel select: "Post name" and save.
Then, go to your Ce Events -> Cities admin screen.
hover over one of your terms (in my case new york city) and click view.
it should open up that term(city)'s list view and the url structure looks like so: http://wp.local/city/new-york-city/
if you need city to read cities, modify line 102 of the main plugin file i shared with you:
'rewrite' => array('slug' => 'city'),
EDIT 2
Why not create City as a Custom Post Type? You can then define a slug 'cities' and get that result, and also add taxonomies like categories and tags to further aid navigation.
Don't do that. WordPress gives you a goog API for doing what you want to do: managing pretty URLs (slugs), database operations (you don't need to write/read files for that) and the right code workflow for registering and triggering actions.
So, I think you have to start reading the basics about WordPress plugins (its philosophy and API) and then just decide if you want to use its custom post types (ready to use) or if you want to create a specific content type.
yes this is fine approach.One more thing that you can do is that instead of adding the code inside the fie..Pick the code from DB.
Make a table in DB,create a column with varchar as datatype and insert the common code in it .
I have a custom posttype in Wordpress 3. I would like to every post of this type to have the option to add a link. Basicly this will be a link that refers to another page/post whatever on the site.
There should be only one link for each post of this type. And i would then need to extract this link in my template files. Basicly im creating a post-type "Slideshow" And each slide-item should be connected to one page or post. So when you click a slide you will be taken to the defined page.
i know i can do this by using a custom-field. But then i would need to enter the whole url every time. I would like a feature similar to that of the wordpress WYSIWYG editor link button. So i can add a link to "existing content" easy.
Anyone know of any tutorials or similar on how to do this?
Thanks!
bit surprised no one has mentioned this plugin "Related Links"
Wordpress plugin Related Links
It adds a metabox to your edit forms. You can link to related content or put in external URL.
It allows links to posts, pages, media AND Custom post type - check its type on the Settings page of the plugin after install. It uses a similar search/browse facility to the normal WYSIWYG link insert feature!
What post-types does it apply to? If you are using on a custom post type, then check all the post-types you want to be able to link to - it still shows the box on this post-type itself.
It can accept multiple links, but one will work of course. Then you use the get_related_link() function in your template to output this and format as you like.
If you just want to make a link between the two posts, rather than insert it in your post content, I'd recommend the Posts 2 Posts plugin. It'll allow you to create links between posts without having to remember the full URL.
Edit:
I haven't used it, but I suspect the cardinality argument should help you limit the number of links - see the wiki.
And you can certainly access the connections in your templates - I have. Once you've registered your connection type, you can just call get_connected:
$venue_details = p2p_type( 'exhibition_to_venues' )->get_connected( $post->ID, array(
'posts_per_page' => -1,
'connected_orderby' => 'order',
'connected_order' => 'ASC' )
);
It seems to me that the best method to accomplish this would be to add a custom meta box to all posts and post types (see here:http://themefoundation.com/wordpress-meta-boxes-guide/). Within this meta box, you can simply query all posts that you would like to include in a dropdown. You can then select the post from that dropdown, obtain the ID of the post selected (use as data attribute in the option field), and then return the permalink for that ID. This will then allow you to simply select the post, rather than having to know the actual URL each time.
Another method would be to attach a piece of unique data to x post (most likely utilizing custom fields), and then also attach it to y post. In this way, you could use a function to automatically append the link to the displayed post. You would do this by querying the posts in the database, match the custom data, and if matched, display the link to that post. This would allow the entire thing to be automated, and you wouldn't even have to select anything. In my opinion, the title field should actually be sufficient for this, since both posts are different post types (you should be able to title them the same), and would likely make your query a bit easier/shorter since you would simply need to find the post that matches the title, and then link to the permalink.
I can elaborate on all of the above further, with code samples as well, but in my opinion, the question is slightly too vague to write a custom script example for this scenario.
I would hope the above would be sufficient to get you going.
WordPress requires you give each blog post at least two fields: a title and text body content.
I'm wondering how to modify WordPress admin so I can sometimes enter a single field for a blog post, in particular a URL, without WordPress requiring a title (related but not the point of this question: a custom theme would then know how to handle a post that only contained a URL, it would treat it like a "Link" post in Tumblr). Ideally it'd be good if the "add/edit post" form could be modified so it only contains this single URL/Link field when this is wanted.
I'm guessing this is possible through a plugin but I'm not certain. I'm hoping some smart WordPress devs are here to share and brainstorm ideas for how this could be done.
Thanks in advance for any help,
Eliot
You could use the display-part of my other answer but, instead of looping only posts, check for 'links' (builtin WP feature) as well. They are easy to manage and you can have many sets of links, which could be used like categories for your regular posts.
The GUI would not handle posts well, for example in the 'post overview' table, which really would need a title.
You could use Wordpress as usual and look for a certain value of a "custom field". Whenever one of your posts has a certain tag (url, for example, or sykes-theme-url if you wish to namespace it), you don't render the post as a usual post but you print out the url together/without a description.
This way you could simply skip printing the post's title for example (much like Tumblr), and instead just post the URL to that-other-place.
See Custom Field-article at Smashing Magazine