MaWe4585
Forum Replies Created
-
I found out, that after the call of ‘the_content(false, false)’ the get_permalink() function doesn’t work anymore, but only in the first run and if there is actually content.
I fixed it by copying the permalink before that into the settings and in the functions.php I read the permalink from the settings instead with get_permalink()<?php elseif ( ( 'full' == $settings[ 'content_type' ] || $more_tag ) && 'none' !== $settings[ 'content_type' ] ) : ?> <div class="wp-show-posts-entry-content" itemprop="text"> <?php the_content( false, false ); ?> </div><!-- .entry-content --> <?php endif;
Forum: Hacks
In reply to: how to begin plugin-developmentThanks a lot for your tips. I’ll definitely take a look into these.
I also stumbled upon an interesting plugin called “Piklist” https://www.ads-software.com/plugins/piklist/ do you know it? It seems pretty easy to handle custom-post-types and fields with it. Can you think of any pros/contras it may have?
Forum: Plugins
In reply to: wpmvc: how to populate belongs_to_dropdown?OK, the problem seems to be the $belongs_to part.
if i do it like above, i have the problem described above.
however if i do it like this:class Town extends MvcModel { var $display_field = 'name'; var $includes = array('Country'); var $belongs_to = array( 'Country' => array( 'foreign_key' => 'country' ), ); }
as described here https://wpmvc.org/documentation/models/associations/
i have the problem from my second post, that when viewing the edit-page, the dropdown is empty even if there is a value in the databaseForum: Plugins
In reply to: wpmvc: how to populate belongs_to_dropdown?OK next problem solved, seems i hat the $belongs_to part in the model wrong.
Now it looks like this:class Town extends MvcModel { var $display_field = 'name'; var $includes = array('Country'); var $belongs_to = array( 'Country' => array( 'local_key' => 'country', 'foreign_key' => 'id' ), ); }
My new problem is that when i edit the town, and change the value of the dropdown, it creates a new town instead of changing the Country of the current town.
Forum: Plugins
In reply to: wpmvc: how to populate belongs_to_dropdown?I managed to do it,
The controler needs methods for edit and add and there a set_countries method needs to be called. in this a list of countries is selected and written to tha $countries variable.
class AdminTownsController extends MvcAdminController { var $default_columns = array('id', 'name'); public function add() { $this->set_countries(); $this->create_or_save(); } public function edit() { $this->set_countries(); $this->verify_id_param(); $this->set_object(); $this->create_or_save(); } function set_countries() { $this->load_model('Country'); $countries = $this->Country->find(array('selects' => array('id', 'name'))); $this->set('countries', $countries); } }
Now i have a new problem with this. I can save my town and assign a country to it. However, when i edit the town the country-dropdown is empty.
in the database i can see it is saved, but the dropdown is still empty.
i think i somehow have to add the selected country to the dropdown, but can’t figure out how.Forum: Hacks
In reply to: select all posts where meta-key doesn't exist or has certain valuei just found an example using get_posts
$args = array( 'post_status'=>'publish', 'post_type' => 'mytype', 'meta_query' => array( array( 'key' => 'example', 'compare' => 'NOT EXISTS' ), ) ); return get_posts($args);
seems it uses the same arguments like WP_Query, i guess it internally uses WP_Query.
Forum: Hacks
In reply to: post-type-relationships with custom-post-typesSince i’m new to WP i actually tried creating custom tables first because i thought that this would be the right way.
A couple days ago i read about custom post types, now i think this may be the better solution. However i have to learn about several things concerning post types.
For example on this page i read about the register_post_type method https://developer.www.ads-software.com/reference/functions/register_post_type/
Here are some things i’m not yet completely familiar with, like the attribute “public”. public=true describes visitors who are not logged in.
However there is no way to describe that the user has to be logged in and also to have one specific role.Good thing i installed a plugin for this…
However what i don’t know is: How do i configure what page is shown if a user clicks a team in a search-result, or if posts from this types should be found at all?
Forum: Hacks
In reply to: post-type-relationships with custom-post-typesI think i may need both, taxonomies and custom post types.
What i want is to create lists of soccer-teams with their players and contests they’re competing in.So i think for the relationship between Teams,Players and Contest i would nee custom post types because i need to add data to each like what position has the team in the league or how many goals did tha player score, or where was the player before he was with this team.
But i think there is other data where i could use taxonomy like the country a player or team belong to.
Forum: Plugins
In reply to: How to use permalinks with my own plugin?I solved it myself. What i need is the Rewrite-API.
I successfully added some rules and tags and now it works fine ??Forum: Plugins
In reply to: Beginning with WordPressHello Xyno1
Thank you very much for the link.
It looks like a plugin where users can sign-up for a newsletter or something. technically it is what i need, forms etc.BUT i just found another plugin which does most of the things i need.
https://www.ads-software.com/plugins/custom-database-tables/
There i can create and alter database-tables and input data in the backend.
so the points 1 and 2 are done.
now i need to read from these tables and view the data.
i think i can learn a thing or two from the custom-database-table plugin and will ask more specific questions one’s i tried to implement point 3 or find a plugin that can help me with it.so i need a plugin that can view data to the user and creates a menu-item into the nav-menu.
also i need a mechanism where i can add a page on which i can add boxes from several plugins via hook or something.